diff options
author | sebres <sebres@users.sourceforge.net> | 2022-08-20 10:13:04 (GMT) |
---|---|---|
committer | sebres <sebres@users.sourceforge.net> | 2022-08-20 10:13:04 (GMT) |
commit | da40e7deb9d3e26315a495419b6ed50f0099bdc7 (patch) | |
tree | d0e159bd1d1e543914720ae0c6f28e874d142065 /win/tclWinConsole.c | |
parent | 228c1134e28746ff7ea71d582ce3b80e68fe030a (diff) | |
download | tcl-da40e7deb9d3e26315a495419b6ed50f0099bdc7.zip tcl-da40e7deb9d3e26315a495419b6ed50f0099bdc7.tar.gz tcl-da40e7deb9d3e26315a495419b6ed50f0099bdc7.tar.bz2 |
closes [baa51423c28a3baf]: needEvent must be initialized in cycle (for each watching channel)
Diffstat (limited to 'win/tclWinConsole.c')
-rw-r--r-- | win/tclWinConsole.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/win/tclWinConsole.c b/win/tclWinConsole.c index 23652de..30a09fd 100644 --- a/win/tclWinConsole.c +++ b/win/tclWinConsole.c @@ -861,21 +861,25 @@ ConsoleCheckProc( handleInfoPtr = FindConsoleInfo(chanInfoPtr); /* Pointer is safe to access as we are holding gConsoleLock */ - if (handleInfoPtr != NULL) { - AcquireSRWLockShared(&handleInfoPtr->lock); - /* Rememebr channel is read or write, never both */ - if (chanInfoPtr->watchMask & TCL_READABLE) { - if (RingBufferLength(&handleInfoPtr->buffer) > 0 - || handleInfoPtr->lastError != ERROR_SUCCESS) { - needEvent = 1; /* Input data available or error/EOF */ - } - } else if (chanInfoPtr->watchMask & TCL_WRITABLE) { - if (RingBufferHasFreeSpace(&handleInfoPtr->buffer)) { - needEvent = 1; /* Output space available */ - } + if (handleInfoPtr == NULL) { + continue; + } + + needEvent = 0; + AcquireSRWLockShared(&handleInfoPtr->lock); + /* Rememebr channel is read or write, never both */ + if (chanInfoPtr->watchMask & TCL_READABLE) { + if (RingBufferLength(&handleInfoPtr->buffer) > 0 + || handleInfoPtr->lastError != ERROR_SUCCESS + ) { + needEvent = 1; /* Input data available or error/EOF */ + } + } else if (chanInfoPtr->watchMask & TCL_WRITABLE) { + if (RingBufferHasFreeSpace(&handleInfoPtr->buffer)) { + needEvent = 1; /* Output space available */ } - ReleaseSRWLockShared(&handleInfoPtr->lock); } + ReleaseSRWLockShared(&handleInfoPtr->lock); if (needEvent) { ConsoleEvent *evPtr = (ConsoleEvent *)ckalloc(sizeof(ConsoleEvent)); |