summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authorculler <culler>2020-06-18 20:02:01 (GMT)
committerculler <culler>2020-06-18 20:02:01 (GMT)
commit8ddfbba120e19cc2736d8664972eaacd58ef0b69 (patch)
treeb45af63be849569d3c72a3af84d0aa3ff9eb91cd /macosx
parent253065d805b9fb1bc634ec0696f04297b2d9e8ed (diff)
downloadtcl-8ddfbba120e19cc2736d8664972eaacd58ef0b69.zip
tcl-8ddfbba120e19cc2736d8664972eaacd58ef0b69.tar.gz
tcl-8ddfbba120e19cc2736d8664972eaacd58ef0b69.tar.bz2
Sometimes the waitTime needs to be positive to avoid missing channel io events.
Diffstat (limited to 'macosx')
-rw-r--r--macosx/tclMacOSXNotify.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/macosx/tclMacOSXNotify.c b/macosx/tclMacOSXNotify.c
index 6f27e64..4ce6786 100644
--- a/macosx/tclMacOSXNotify.c
+++ b/macosx/tclMacOSXNotify.c
@@ -255,8 +255,6 @@ typedef struct ThreadSpecificData {
int runLoopRunning; /* True if this thread's Tcl runLoop is
* running. */
int runLoopNestingLevel; /* Level of nested runLoop invocations. */
- int runLoopServicingEvents; /* True if this thread's runLoop is servicing
- * Tcl events. */
/* Must hold the notifierLock before accessing the following fields: */
/* Start notifierLock section */
@@ -1225,7 +1223,7 @@ Tcl_WaitForEvent(
/*
* A NULL timePtr means wait forever.
*/
-
+
if (timePtr) {
Tcl_Time vTime = *timePtr;
@@ -1242,15 +1240,25 @@ Tcl_WaitForEvent(
/*
* The max block time was set to 0.
+ *
+ * If we set the waitTime to 0, then the call to CFRunLoopInMode
+ * may return without processing all of its sources. The Apple
+ * documentation says that if the waitTime is 0 "only one pass is
+ * made through the run loop before returning; if multiple sources
+ * or timers are ready to fire immediately, only one (possibly two
+ * if one is a version 0 source) will be fired, regardless of the
+ * value of returnAfterSourceHandled." This can cause some chanio
+ * tests to fail. So we use a small positive waitTime unless there
+ * is another RunLoop running.
*/
polling = 1;
- waitTime = 0;
+ waitTime = tsdPtr->runLoopRunning ? 0 : 0.0001;
}
}
StartNotifierThread();
-
+
LOCK_NOTIFIER_TSD;
tsdPtr->polling = polling;
UNLOCK_NOTIFIER_TSD;