115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
* notifiers.
*
* You must hold the notifierMutex lock before accessing this variable.
*/
static int notifierCount = 0;
/*
* The following variable points to the head of a doubly-linked list of
* ThreadSpecificData structures for all threads that are currently waiting on
* an event.
*
* You must hold the notifierMutex lock before accessing this list.
*/
|
>
>
>
>
>
>
>
>
>
|
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
* notifiers.
*
* You must hold the notifierMutex lock before accessing this variable.
*/
static int notifierCount = 0;
/*
* The following static stores the process ID of the initialized notifier
* thread. If it changes, we have passed a fork and we should start a new
* notifier thread.
*
* You must hold the notifierMutex lock before accessing this variable.
*/
static pid_t processIDInitialized = 0;
/*
* The following variable points to the head of a doubly-linked list of
* ThreadSpecificData structures for all threads that are currently waiting on
* an event.
*
* You must hold the notifierMutex lock before accessing this list.
*/
|
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
|
tsdPtr->eventReady = 0;
/*
* Start the Notifier thread if necessary.
*/
Tcl_MutexLock(¬ifierMutex);
if (notifierCount == 0) {
if (TclpThreadCreate(¬ifierThread, NotifierThreadProc, NULL,
TCL_THREAD_STACK_DEFAULT, TCL_THREAD_JOINABLE) != TCL_OK) {
Tcl_Panic("Tcl_InitNotifier: unable to start notifier thread");
}
}
notifierCount++;
/*
* Wait for the notifier pipe to be created.
*/
|
>
>
>
>
>
>
>
>
>
>
>
>
|
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
|
tsdPtr->eventReady = 0;
/*
* Start the Notifier thread if necessary.
*/
Tcl_MutexLock(¬ifierMutex);
/*
* Check if my process id changed, e.g. I was forked
* In this case, restart the notifier thread and close the
* pipe to the original notifier thread
*/
if (notifierCount > 0 && processIDInitialized != getpid()) {
notifierCount = 0;
processIDInitialized = 0;
close(triggerPipe);
triggerPipe = -1;
}
if (notifierCount == 0) {
if (TclpThreadCreate(¬ifierThread, NotifierThreadProc, NULL,
TCL_THREAD_STACK_DEFAULT, TCL_THREAD_JOINABLE) != TCL_OK) {
Tcl_Panic("Tcl_InitNotifier: unable to start notifier thread");
}
processIDInitialized = getpid();
}
notifierCount++;
/*
* Wait for the notifier pipe to be created.
*/
|