diff Python/import.c @ 59210:4afc50d15544 legacy-trunk

Issue #7242: On Solaris 9 and earlier calling os.fork() from within a thread could raise an incorrect RuntimeError about not holding the import lock. The import lock is now reinitialized after fork.
author Gregory P. Smith <greg@mad-scientist.com>
date Mon, 01 Mar 2010 01:22:39 +0000
parents edfed0e32ced
children 4468666d01c4
line wrap: on
line diff
--- a/Python/import.c	Mon Mar 01 00:05:08 2010 +0000
+++ b/Python/import.c	Mon Mar 01 01:22:39 2010 +0000
@@ -301,14 +301,18 @@
 	return 1;
 }
 
-/* This function used to be called from PyOS_AfterFork to ensure that newly
-   created child processes do not share locks with the parent, but for some
-   reason only on AIX systems. Instead of re-initializing the lock, we now
-   acquire the import lock around fork() calls. */
+/* This function is called from PyOS_AfterFork to ensure that newly
+   created child processes do not share locks with the parent.
+   We now acquire the import lock around fork() calls but on some platforms
+   (Solaris 9 and earlier? see isue7242) that still left us with problems. */
 
 void
 _PyImport_ReInitLock(void)
 {
+ 	if (import_lock != NULL)
+ 		import_lock = PyThread_allocate_lock();
+ 	import_lock_thread = -1;
+ 	import_lock_level = 0;
 }
 
 #endif