[Python-checkins] CVS: python/dist/src/Python ceval.c,2.195,2.196
Guido van Rossum
python-dev@python.org
Sun, 27 Aug 2000 10:33:19 -0700
Update of /cvsroot/python/python/dist/src/Python
In directory slayer.i.sourceforge.net:/tmp/cvs-serv4141
Modified Files:
ceval.c
Log Message:
Charles Waldman's patch to reinitialize the interpreter lock after a
fork. This solves the test_fork1 problem. (ceval.c, signalmodule.c,
intrcheck.c)
SourceForge: [ Patch #101226 ] make threading fork-safe
Index: ceval.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v
retrieving revision 2.195
retrieving revision 2.196
diff -C2 -r2.195 -r2.196
*** ceval.c 2000/08/24 20:11:31 2.195
--- ceval.c 2000/08/27 17:33:16 2.196
***************
*** 143,146 ****
--- 143,165 ----
PyThread_release_lock(interpreter_lock);
}
+
+ /* This function is called from PyOS_AfterFork to ensure that newly
+ created child processes don't hold locks referring to threads which
+ are not running in the child process. (This could also be done using
+ pthread_atfork mechanism, at least for the pthreads implementation.) */
+
+ void
+ PyEval_ReInitThreads(void)
+ {
+ if (!interpreter_lock)
+ return;
+ /*XXX Can't use PyThread_free_lock here because it does too
+ much error-checking. Doing this cleanly would require
+ adding a new function to each thread_*.h. Instead, just
+ create a new lock and waste a little bit of memory */
+ interpreter_lock = PyThread_allocate_lock();
+ PyThread_acquire_lock(interpreter_lock, 1);
+ main_thread = PyThread_get_thread_ident();
+ }
#endif