pike.git / src / threads.c

version» Context lines:

pike.git/src/threads.c:531:    USE_DLOC_ARGS();    THREADS_FPRINTF (1, "Releasing iplock @ %s:%d\n", DLOC_ARGS_OPT);    UNSET_LOCKING_THREAD;    mt_unlock (&interpreter_lock);   }      PMOD_EXPORT void pike_wait_interpreter (COND_T *cond COMMA_DLOC_DECL)   {    int owner = threads_disabled;    pike_low_wait_interpreter (cond COMMA_DLOC_ARGS_OPT); -  if (!owner && threads_disabled) threads_disabled_wait (DLOC_ARGS_OPT); +  if (!owner && threads_disabled) { +  /* Some other thread has disabled threads while we were waiting +  * for the cond var. We must wait for threads to be reenabled +  * before proceeding. +  */ +  threads_disabled_wait (DLOC_ARGS_OPT);    } -  + }      PMOD_EXPORT int pike_timedwait_interpreter (COND_T *cond,    long sec, long nsec    COMMA_DLOC_DECL)   {    int owner = threads_disabled;    int res = pike_low_timedwait_interpreter (cond, sec, nsec    COMMA_DLOC_ARGS_OPT); -  if (!owner && threads_disabled) threads_disabled_wait (DLOC_ARGS_OPT); +  if (!owner && threads_disabled) { +  /* Some other thread has disabled threads while we were waiting +  * for the cond var. We must wait for threads to be reenabled +  * before proceeding. +  */ +  threads_disabled_wait (DLOC_ARGS_OPT); +  }    return res;   }      PMOD_EXPORT void pike_init_thread_state (struct thread_state *ts)   {    /* NB: Assumes that there's a temporary Pike_interpreter_struct    * in Pike_interpreter_pointer, which we copy, and replace    * with ourselves.    */    Pike_interpreter.thread_state = ts;