summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorNeil Schemenauer <nascheme@enme.ucalgary.ca>2001-10-31 23:09:35 (GMT)
committerNeil Schemenauer <nascheme@enme.ucalgary.ca>2001-10-31 23:09:35 (GMT)
commite8c40cb72245ac7271e61c1b40f5812a8f041fcf (patch)
tree88f39dcd2cf3382b66baf4398ec6231385b47dec /Modules
parent67050d2d64558e46c63d4538b06653e7165a28c6 (diff)
downloadcpython-e8c40cb72245ac7271e61c1b40f5812a8f041fcf.zip
cpython-e8c40cb72245ac7271e61c1b40f5812a8f041fcf.tar.gz
cpython-e8c40cb72245ac7271e61c1b40f5812a8f041fcf.tar.bz2
Make the gc.collect() function respect the collection lock. This fixes
SF bug 476129: "gc.collect sometimes hangs".
Diffstat (limited to 'Modules')
-rw-r--r--Modules/gcmodule.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c
index ed846cc..0badc23 100644
--- a/Modules/gcmodule.c
+++ b/Modules/gcmodule.c
@@ -548,10 +548,17 @@ gc_collect(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, ":collect")) /* check no args */
return NULL;
- generation = 2;
- gc_list_merge(&_PyGC_generation0, &generation2);
- gc_list_merge(&generation1, &generation2);
- n = collect(&generation2, &generation2);
+ if (collecting) {
+ n = 0; /* already collecting, don't do anything */
+ }
+ else {
+ collecting = 1;
+ generation = 2;
+ gc_list_merge(&_PyGC_generation0, &generation2);
+ gc_list_merge(&generation1, &generation2);
+ n = collect(&generation2, &generation2);
+ collecting = 0;
+ }
return Py_BuildValue("l", n);
}