[Python-checkins] cpython (3.2): Issue #10363: Deallocate global locks in Py_Finalize().
antoine.pitrou
python-checkins at python.org
Sun Oct 30 19:19:47 CET 2011
http://hg.python.org/cpython/rev/608975eafe86
changeset: 73205:608975eafe86
branch: 3.2
parent: 73203:b643458a0108
user: Antoine Pitrou <solipsis at pitrou.net>
date: Sun Oct 30 19:13:55 2011 +0100
summary:
Issue #10363: Deallocate global locks in Py_Finalize().
files:
Misc/NEWS | 2 ++
Python/import.c | 25 +++++++++++++++----------
Python/pystate.c | 6 ++++++
3 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,8 @@
Core and Builtins
-----------------
+- Issue #10363: Deallocate global locks in Py_Finalize().
+
- Issue #13018: Fix reference leaks in error paths in dictobject.c.
Patch by Suman Saha.
diff --git a/Python/import.c b/Python/import.c
--- a/Python/import.c
+++ b/Python/import.c
@@ -252,16 +252,6 @@
Py_DECREF(path_hooks);
}
-void
-_PyImport_Fini(void)
-{
- Py_XDECREF(extensions);
- extensions = NULL;
- PyMem_DEL(_PyImport_Filetab);
- _PyImport_Filetab = NULL;
-}
-
-
/* Locking primitives to prevent parallel imports of the same module
in different threads to return with a partially loaded module.
These calls are serialized by the global interpreter lock. */
@@ -374,6 +364,21 @@
return Py_None;
}
+void
+_PyImport_Fini(void)
+{
+ Py_XDECREF(extensions);
+ extensions = NULL;
+ PyMem_DEL(_PyImport_Filetab);
+ _PyImport_Filetab = NULL;
+#ifdef WITH_THREAD
+ if (import_lock != NULL) {
+ PyThread_free_lock(import_lock);
+ import_lock = NULL;
+ }
+#endif
+}
+
static void
imp_modules_reloading_clear(void)
{
diff --git a/Python/pystate.c b/Python/pystate.c
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -150,6 +150,12 @@
*p = interp->next;
HEAD_UNLOCK();
free(interp);
+#ifdef WITH_THREAD
+ if (interp_head == NULL && head_mutex != NULL) {
+ PyThread_free_lock(head_mutex);
+ head_mutex = NULL;
+ }
+#endif
}
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list