summaryrefslogtreecommitdiffstats
path: root/Python/import.c
diff options
context:
space:
mode:
authorDong-hee Na <donghee.na92@gmail.com>2020-04-14 16:16:24 (GMT)
committerGitHub <noreply@github.com>2020-04-14 16:16:24 (GMT)
commit62f75fe3dd138f72303814d27183aa469eefcca6 (patch)
tree9d9a3dc0356561974b26f17b65a0a0da18f4ad4d /Python/import.c
parente5014be0497d06d78343623588a80f491a6f7b74 (diff)
downloadcpython-62f75fe3dd138f72303814d27183aa469eefcca6.zip
cpython-62f75fe3dd138f72303814d27183aa469eefcca6.tar.gz
cpython-62f75fe3dd138f72303814d27183aa469eefcca6.tar.bz2
bpo-40232: Update PyOS_AfterFork_Child() to use _PyThread_at_fork_reinit() (GH-19450)
Diffstat (limited to 'Python/import.c')
-rw-r--r--Python/import.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Python/import.c b/Python/import.c
index 8a2f9de..4933463 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -200,6 +200,7 @@ _PyImport_ReleaseLock(void)
return 1;
}
+#ifdef HAVE_FORK
/* This function is called from PyOS_AfterFork_Child 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
@@ -209,8 +210,7 @@ void
_PyImport_ReInitLock(void)
{
if (import_lock != NULL) {
- import_lock = PyThread_allocate_lock();
- if (import_lock == NULL) {
+ if (_PyThread_at_fork_reinit(&import_lock) < 0) {
_Py_FatalErrorFunc(__func__, "failed to create a new lock");
}
}
@@ -229,6 +229,7 @@ _PyImport_ReInitLock(void)
import_lock_level = 0;
}
}
+#endif
/*[clinic input]
_imp.lock_held