Branch: Tag:

2001-11-01

2001-11-01 18:10:28 by Martin Stjernholm <mast@lysator.liu.se>

Always wait on threads_disabled in mt_lock_interpreter,
mt_trylock_interpreter and co_wait_interpreter. This fixes bugs where
the _disable_threads lock could fail to hold the threads if there are
threads dependent on uid or similar running when the _disable_threads
lock is requested. This bug could cause numerous "Cannot wait for
mutexes/conditions when threads are disabled" backtraces when
_disable_threads is used (e.g. through the Privs class in Roxen). Cf
[bug 1173 (#1173)].

Use the new macros low_mt_lock_interpreter etc in the places where we
can run even if threads_disabled is set.

Rev: src/pike_threadlib.h:1.7
Rev: src/signal_handler.c:1.208
Rev: src/threads.c:1.171

1:   #include "global.h" - RCSID("$Id: threads.c,v 1.170 2001/10/28 18:02:49 nilsson Exp $"); + RCSID("$Id: threads.c,v 1.171 2001/11/01 18:10:28 mast Exp $");      PMOD_EXPORT int num_threads = 1;   PMOD_EXPORT int threads_disabled = 0;
286:    (stderr,    "_disable_threads(): Waiting for %d threads to finish\n",    live_threads)); -  co_wait_interpreter(&live_threads_change); +  low_co_wait_interpreter(&live_threads_change);    }    SWAP_IN_CURRENT_THREAD();    }
1659:   #endif /* POSIX_THREADS */       mt_init( & interpreter_lock); -  mt_lock_interpreter(); +  low_mt_lock_interpreter();    mt_init( & thread_table_lock);    mt_init( & interleave_lock);    mt_init( & rosie);