summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixNotfy.c
diff options
context:
space:
mode:
Diffstat (limited to 'unix/tclUnixNotfy.c')
-rw-r--r--unix/tclUnixNotfy.c76
1 files changed, 61 insertions, 15 deletions
diff --git a/unix/tclUnixNotfy.c b/unix/tclUnixNotfy.c
index c1f00d5..e7e70ef 100644
--- a/unix/tclUnixNotfy.c
+++ b/unix/tclUnixNotfy.c
@@ -350,24 +350,24 @@ AlertSingleThread(
{
tsdPtr->eventReady = 1;
if (tsdPtr->onList) {
- /*
- * Remove the ThreadSpecificData structure of this thread from the
- * waiting list. This prevents us from continuously spinning on
- * epoll_wait until the other threads runs and services the file
- * event.
- */
-
- if (tsdPtr->prevPtr) {
+ /*
+ * Remove the ThreadSpecificData structure of this thread from the
+ * waiting list. This prevents us from continuously spinning on
+ * epoll_wait until the other threads runs and services the file
+ * event.
+ */
+
+ if (tsdPtr->prevPtr) {
tsdPtr->prevPtr->nextPtr = tsdPtr->nextPtr;
- } else {
+ } else {
waitingListPtr = tsdPtr->nextPtr;
- }
- if (tsdPtr->nextPtr) {
+ }
+ if (tsdPtr->nextPtr) {
tsdPtr->nextPtr->prevPtr = tsdPtr->prevPtr;
- }
- tsdPtr->nextPtr = tsdPtr->prevPtr = NULL;
- tsdPtr->onList = 0;
- tsdPtr->pollState = 0;
+ }
+ tsdPtr->nextPtr = tsdPtr->prevPtr = NULL;
+ tsdPtr->onList = 0;
+ tsdPtr->pollState = 0;
}
#ifdef __CYGWIN__
PostMessageW(tsdPtr->hwnd, 1024, 0, 0);
@@ -403,6 +403,10 @@ AtForkChild(void)
pthread_mutex_init(&notifierMutex, NULL);
pthread_cond_init(&notifierCV, NULL);
+#ifdef NOTIFIER_SELECT
+ asyncPending = 0;
+#endif
+
/*
* notifierThreadRunning == 1: thread is running, (there might be data in
* notifier lists)
@@ -420,6 +424,10 @@ AtForkChild(void)
close(triggerPipe);
triggerPipe = -1;
+#ifdef NOTIFIER_SELECT
+ close(otherPipe);
+ otherPipe = -1;
+#endif
/*
* The waitingListPtr might contain event info from multiple
* threads, which are invalid here, so setting it to NULL is not
@@ -456,6 +464,14 @@ AtForkChild(void)
}
Tcl_InitNotifier();
+
+#ifdef NOTIFIER_SELECT
+ /*
+ * Restart the notifier thread for signal handling.
+ */
+
+ StartNotifierThread("AtForkChild");
+#endif
}
#endif /* HAVE_PTHREAD_ATFORK */
#endif /* TCL_THREADS */
@@ -464,6 +480,36 @@ AtForkChild(void)
/*
*----------------------------------------------------------------------
*
+ * TclpNotifierData --
+ *
+ * This function returns a ClientData pointer to be associated
+ * with a Tcl_AsyncHandler.
+ *
+ * Results:
+ * For the epoll and kqueue notifiers, this function returns the
+ * thread specific data. Otherwise NULL.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+ClientData
+TclpNotifierData(void)
+{
+#if defined(NOTIFIER_EPOLL) || defined(NOTIFIER_KQUEUE)
+ ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
+
+ return (ClientData) tsdPtr;
+#else
+ return NULL;
+#endif
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TclUnixWaitForFile --
*
* This function waits synchronously for a file to become readable or