summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixNotfy.c
diff options
context:
space:
mode:
Diffstat (limited to 'unix/tclUnixNotfy.c')
-rw-r--r--unix/tclUnixNotfy.c50
1 files changed, 20 insertions, 30 deletions
diff --git a/unix/tclUnixNotfy.c b/unix/tclUnixNotfy.c
index a78cabd..916951f 100644
--- a/unix/tclUnixNotfy.c
+++ b/unix/tclUnixNotfy.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclUnixNotfy.c,v 1.34 2008/03/11 22:23:50 das Exp $
+ * RCS: @(#) $Id: tclUnixNotfy.c,v 1.34.2.1 2009/04/10 18:02:42 das Exp $
*/
#include "tclInt.h"
@@ -143,7 +143,7 @@ static ThreadSpecificData *waitingListPtr = NULL;
* pipe. Hence writing to this file descriptor will cause the select() system
* call to return and wake up the notifier thread.
*
- * You must hold the notifierMutex lock before accessing this list.
+ * You must hold the notifierMutex lock before writing to the pipe.
*/
static int triggerPipe = -1;
@@ -199,7 +199,7 @@ static int FileHandlerEventProc(Tcl_Event *evPtr, int flags);
* Initializes the platform specific notifier state.
*
* Results:
- * Returns a handle to the notifier state for this thread..
+ * Returns a handle to the notifier state for this thread.
*
* Side effects:
* None.
@@ -543,15 +543,17 @@ Tcl_DeleteFileHandler(
*/
if (fd+1 == tsdPtr->numFdBits) {
- tsdPtr->numFdBits = 0;
+ int numFdBits = 0;
+
for (i = fd-1; i >= 0; i--) {
if (FD_ISSET(i, &(tsdPtr->checkMasks.readable))
|| FD_ISSET(i, &(tsdPtr->checkMasks.writable))
|| FD_ISSET(i, &(tsdPtr->checkMasks.exceptional))) {
- tsdPtr->numFdBits = i+1;
+ numFdBits = i+1;
break;
}
}
+ tsdPtr->numFdBits = numFdBits;
}
/*
@@ -664,10 +666,9 @@ Tcl_WaitForEvent(
FileHandler *filePtr;
FileHandlerEvent *fileEvPtr;
int mask;
- Tcl_Time myTime;
+ Tcl_Time vTime;
#ifdef TCL_THREADS
int waitForFiles;
- Tcl_Time *myTimePtr;
#else
/*
* Impl. notes: timeout & timeoutPtr are used if, and only if threads are
@@ -696,22 +697,15 @@ Tcl_WaitForEvent(
* handler to do this scaling.
*/
- myTime.sec = timePtr->sec;
- myTime.usec = timePtr->usec;
-
- if (myTime.sec != 0 || myTime.usec != 0) {
- (*tclScaleTimeProcPtr) (&myTime, tclTimeClientData);
+ if (timePtr->sec != 0 || timePtr->usec != 0) {
+ vTime = *timePtr;
+ (*tclScaleTimeProcPtr) (&vTime, tclTimeClientData);
+ timePtr = &vTime;
}
-
-#ifdef TCL_THREADS
- myTimePtr = &myTime;
-#else
- timeout.tv_sec = myTime.sec;
- timeout.tv_usec = myTime.usec;
- timeoutPtr = &timeout;
-#endif /* TCL_THREADS */
-
#ifndef TCL_THREADS
+ timeout.tv_sec = timePtr->sec;
+ timeout.tv_usec = timePtr->usec;
+ timeoutPtr = &timeout;
} else if (tsdPtr->numFdBits == 0) {
/*
* If there are no threads, no timeout, and no fds registered, then
@@ -722,11 +716,7 @@ Tcl_WaitForEvent(
*/
return -1;
-#endif /* !TCL_THREADS */
} else {
-#ifdef TCL_THREADS
- myTimePtr = NULL;
-#else
timeoutPtr = NULL;
#endif /* TCL_THREADS */
}
@@ -739,8 +729,7 @@ Tcl_WaitForEvent(
Tcl_MutexLock(&notifierMutex);
- waitForFiles = (tsdPtr->numFdBits > 0);
- if (myTimePtr != NULL && myTimePtr->sec == 0 && (myTimePtr->usec == 0
+ if (timePtr != NULL && timePtr->sec == 0 && (timePtr->usec == 0
#if defined(__APPLE__) && defined(__LP64__)
/*
* On 64-bit Darwin, pthread_cond_timedwait() appears to have a bug
@@ -748,7 +737,7 @@ Tcl_WaitForEvent(
* has already been exceeded by the system time; as a workaround,
* when given a very brief timeout, just do a poll. [Bug 1457797]
*/
- || myTimePtr->usec < 10
+ || timePtr->usec < 10
#endif
)) {
/*
@@ -761,8 +750,9 @@ Tcl_WaitForEvent(
waitForFiles = 1;
tsdPtr->pollState = POLL_WANT;
- myTimePtr = NULL;
+ timePtr = NULL;
} else {
+ waitForFiles = (tsdPtr->numFdBits > 0);
tsdPtr->pollState = 0;
}
@@ -789,7 +779,7 @@ Tcl_WaitForEvent(
FD_ZERO(&(tsdPtr->readyMasks.exceptional));
if (!tsdPtr->eventReady) {
- Tcl_ConditionWait(&tsdPtr->waitCV, &notifierMutex, myTimePtr);
+ Tcl_ConditionWait(&tsdPtr->waitCV, &notifierMutex, timePtr);
}
tsdPtr->eventReady = 0;