summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsebres <sebres@users.sourceforge.net>2017-07-10 08:59:08 (GMT)
committersebres <sebres@users.sourceforge.net>2017-07-10 08:59:08 (GMT)
commit36d3c6b3d97e0f57c2ce91ead998c66dd84e9411 (patch)
tree987c96710efaeed711f9c66ae7ad5b4d9cce66e1
parent1eda39625d8db0707bd1584697f58afde2494f12 (diff)
downloadtcl-36d3c6b3d97e0f57c2ce91ead998c66dd84e9411.zip
tcl-36d3c6b3d97e0f57c2ce91ead998c66dd84e9411.tar.gz
tcl-36d3c6b3d97e0f57c2ce91ead998c66dd84e9411.tar.bz2
tclUnixNotfy.c: we should wait for notifier at least once in case of waitForFiles (regardless of the too short timeout), e. g. test case "chan-io-53.8", etc.
-rw-r--r--unix/tclUnixNotfy.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/unix/tclUnixNotfy.c b/unix/tclUnixNotfy.c
index 81d8e7f..0d5d87b 100644
--- a/unix/tclUnixNotfy.c
+++ b/unix/tclUnixNotfy.c
@@ -994,6 +994,10 @@ Tcl_WaitForEvent(
if (timePtr != NULL) {
waitTime = TCL_TIME_TO_USEC(*timePtr);
+ /*
+ * Note the time can be switched (time-jump), so use monotonic time here.
+ */
+ endTime = TclpGetUTimeMonotonic() + waitTime;
/*
* If short wait or no wait at all, just process events already available
@@ -1002,11 +1006,6 @@ Tcl_WaitForEvent(
if (!timePtr->sec && timePtr->usec < TCL_TMR_MIN_DELAY) {
canWait = 0;
- } else {
- /*
- * Note the time can be switched (time-jump), so use monotonic time here.
- */
- endTime = TclpGetUTimeMonotonic() + waitTime;
}
#ifndef TCL_THREADS
@@ -1038,12 +1037,13 @@ Tcl_WaitForEvent(
pthread_mutex_lock(&notifierMutex);
+ waitForFiles = (tsdPtr->numFdBits > 0);
+
/* if cannot wait (but not really necessary to wait), bypass triggering pipe */
- if (!canWait && (!tsdPtr->numFdBits || tsdPtr->eventReady)) {
+ if (!canWait && (!waitForFiles || tsdPtr->eventReady)) {
goto nowait;
}
- waitForFiles = (tsdPtr->numFdBits > 0);
if (!canWait) {
/*
* Cannot emulate a polling select with a polling condition
@@ -1055,6 +1055,7 @@ Tcl_WaitForEvent(
if (waitForFiles) {
tsdPtr->pollState = POLL_WANT;
+ canWait = 1;
}
} else {
tsdPtr->pollState = 0;
@@ -1093,11 +1094,20 @@ Tcl_WaitForEvent(
waitTime = endTime - TclpGetUTimeMonotonic();
+ /* Note: we should wait at least once if waitForFiles set */
if (waitTime <= 0) {
- break; /* end of wait */
+ if (!waitForFiles) {
+ break; /* end of wait */
+ }
+ waitForFiles = 0;
+ waitTime = 0;
}
+ else
if (waitTime <= TCL_TMR_OVERHEAD) {
- canWait = 0;
+ if (!waitForFiles) {
+ canWait = 0;
+ }
+ waitForFiles = 0;
}
}
@@ -1202,7 +1212,7 @@ Tcl_WaitForEvent(
ResetEvent(tsdPtr->event);
# endif /* __CYGWIN__ */
- if (waitForFiles && tsdPtr->onList) {
+ if (tsdPtr->onList) {
/*
* Remove the ThreadSpecificData structure of this thread from the
* waiting list. Alert the notifier thread to recompute its select