Tcl Source Code

View Ticket
Login
Ticket UUID: 849007
Title: bug in Tcl_ConditionNotify for win build
Type: Bug Created on: 2003-11-25 15:03:36
Submitter: nobody Assigned to: davygrvy
Subsystem: 49. Threading Severity:
Priority: 5 Medium Last modified: 2004-01-12 03:39:32
Status: Closed Closed by: davygrvy
Resolution: Fixed Closed on: 2004-01-11 20:39:32
Version: obsolete: 8.4.5
Description:
in the first if, need the '*' !! (ie. *condPtr)
the following code, is after the fix.

void
Tcl_ConditionNotify(condPtr)
    Tcl_Condition *condPtr;
{
    WinCondition *winCondPtr;
    ThreadSpecificData *tsdPtr;
    if (*condPtr != NULL) {
winCondPtr = *((WinCondition **)condPtr);

/*
 * Loop through all the threads waiting on the 
condition
 * and notify them (i.e., broadcast 
semantics).  The queue
 * manipulation is guarded by the per-
condition coordinating mutex.
 */

EnterCriticalSection(&winCondPtr->condLock);
while (winCondPtr->firstPtr != NULL) {
    tsdPtr = winCondPtr->firstPtr;
    winCondPtr->firstPtr = tsdPtr->nextPtr;
    if (winCondPtr->lastPtr == tsdPtr) {
winCondPtr->lastPtr = NULL;
    }
    tsdPtr->flags = WIN_THREAD_RUNNING;
    tsdPtr->nextPtr = NULL;
    tsdPtr->prevPtr = NULL;/* Not strictly 
necessary, see A: */
    SetEvent(tsdPtr->condEvent);
}
LeaveCriticalSection(&winCondPtr->condLock);
    } else {
/*
 * Noone has used the condition variable, so 
there are no waiters.
 */
    }
}
User Comments:
davygrvy added on 2003-12-06 01:51:52:
Logged In: YES 
user_id=7549

Could the author please explain this.  I don't seem to 
understand.  What's the diff to the current code?

davygrvy added on 2004-01-12 03:31:29:
Logged In: YES 
user_id=7549

I see the fix now, and is valid.  The old 'if (condPtr != NULL)' 
will always be true.  Yes, must be dereferenced.

davygrvy added on 2004-01-12 03:39:32:
Logged In: YES 
user_id=7549

change committed to HEAD.