* by a mutex. This will prevent another thread from stealing the signal */
if( !p_condvar->semaphore )
{
+ /*
+ ** PulseEvent() only works if none of the waiting threads is suspended.
+ ** this is particularily problematic under a debug session.
+ ** as documented in http://support.microsoft.com/kb/q173260/
+ */
PulseEvent( p_condvar->event );
}
else if( p_condvar->i_win9x_cv == 1 )
DWORD result;
if( delay_ms < 0 )
- delay_ms = 0;
+ delay_ms = 0;
p_condvar->i_waiting_threads++;
LeaveCriticalSection( &p_mutex->csection );
mtime_t delay_ms = (deadline - mdate())/1000;
if( delay_ms < 0 )
- delay_ms = 0;
+ delay_ms = 0;
if( !p_condvar->semaphore )
{
/* Wait for the gate to be open */
result = WaitForSingleObject( p_condvar->event, delay_ms );
- /* recaculate remaining delay */
- delay_ms = (deadline - mdate())/1000;
- if( delay_ms < 0 )
- delay_ms = 0;
-
/* Increase our wait count */
p_condvar->i_waiting_threads++;
LeaveCriticalSection( &p_mutex->csection );
- if( !result )
- result = WaitForSingleObject( p_condvar->semaphore, delay_ms );
+ if( !result )
+ {
+ /* recaculate remaining delay */
+ delay_ms = (deadline - mdate())/1000;
+ if( delay_ms < 0 )
+ delay_ms = 0;
+
+ result = WaitForSingleObject( p_condvar->semaphore, delay_ms );
+ }
/* Decrement and test must be atomic */
EnterCriticalSection( &p_condvar->csection );