From dfda01d97f073673635b19ca1f6a2ee7ee94db16 Mon Sep 17 00:00:00 2001 From: pooryorick Date: Thu, 4 Apr 2024 11:50:51 +0000 Subject: Possibly a fix for [080f846fd58958ef]: When updating the interest of a channel, don't schedule the channel handler timer if a nonblocking channel doesn't yet have a buffer or if the buffer is empty or overflowing. Where asynchronous connection state is concerned, this should mean that the time won't be scheduled if the initial connection isn't established. --- generic/tclIO.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/generic/tclIO.c b/generic/tclIO.c index 4b5cb7d..c836342 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -8631,6 +8631,7 @@ UpdateInterest( { ChannelState *statePtr = chanPtr->state; /* State info for channel */ + ChannelBuffer *bufPtr = statePtr->outQueueHead; int mask = statePtr->interestMask; if (chanPtr->typePtr == NULL) { @@ -8711,7 +8712,15 @@ UpdateInterest( if (!statePtr->timer && mask & TCL_WRITABLE - && GotFlag(statePtr, CHANNEL_NONBLOCKING)) { + && GotFlag(statePtr, CHANNEL_NONBLOCKING) + && ( + bufPtr + && + !IsBufferEmpty(bufPtr) + && + !IsBufferFull(bufPtr) + ) + ) { TclChannelPreserve((Tcl_Channel)chanPtr); statePtr->timerChanPtr = chanPtr; statePtr->timer = Tcl_CreateTimerHandler(SYNTHETIC_EVENT_TIME, -- cgit v0.12