summaryrefslogtreecommitdiffstats
path: root/Python/import.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/import.c')
-rw-r--r--Python/import.c31
1 files changed, 12 insertions, 19 deletions
diff --git a/Python/import.c b/Python/import.c
index e143322..1129a7f 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -261,8 +261,8 @@ static PyThread_type_lock import_lock = 0;
static long import_lock_thread = -1;
static int import_lock_level = 0;
-static void
-lock_import(void)
+void
+_PyImport_AcquireLock(void)
{
long me = PyThread_get_thread_ident();
if (me == -1)
@@ -286,8 +286,8 @@ lock_import(void)
import_lock_level = 1;
}
-static int
-unlock_import(void)
+int
+_PyImport_ReleaseLock(void)
{
long me = PyThread_get_thread_ident();
if (me == -1 || import_lock == NULL)
@@ -302,23 +302,16 @@ unlock_import(void)
return 1;
}
-/* This function is called from PyOS_AfterFork to ensure that newly
- created child processes do not share locks with the parent. */
+/* 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. */
void
_PyImport_ReInitLock(void)
{
-#ifdef _AIX
- if (import_lock != NULL)
- import_lock = PyThread_allocate_lock();
-#endif
}
-#else
-
-#define lock_import()
-#define unlock_import() 0
-
#endif
static PyObject *
@@ -335,7 +328,7 @@ static PyObject *
imp_acquire_lock(PyObject *self, PyObject *noargs)
{
#ifdef WITH_THREAD
- lock_import();
+ _PyImport_AcquireLock();
#endif
Py_INCREF(Py_None);
return Py_None;
@@ -345,7 +338,7 @@ static PyObject *
imp_release_lock(PyObject *self, PyObject *noargs)
{
#ifdef WITH_THREAD
- if (unlock_import() < 0) {
+ if (_PyImport_ReleaseLock() < 0) {
PyErr_SetString(PyExc_RuntimeError,
"not holding the import lock");
return NULL;
@@ -2200,9 +2193,9 @@ PyImport_ImportModuleLevel(char *name, PyObject *globals, PyObject *locals,
PyObject *fromlist, int level)
{
PyObject *result;
- lock_import();
+ _PyImport_AcquireLock();
result = import_module_level(name, globals, locals, fromlist, level);
- if (unlock_import() < 0) {
+ if (_PyImport_ReleaseLock() < 0) {
Py_XDECREF(result);
PyErr_SetString(PyExc_RuntimeError,
"not holding the import lock");