[Python-checkins] CVS: python/dist/src/Modules gcmodule.c,2.15,2.15.6.1
Anthony Baxter
anthonybaxter@users.sourceforge.net
Thu, 01 Nov 2001 07:34:23 -0800
Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv23756
Modified Files:
Tag: release21-maint
gcmodule.c
Log Message:
one more for the night.
backport of 2.26:
Make the gc.collect() function respect the collection lock. This fixes
SF bug 476129: "gc.collect sometimes hangs".
Index: gcmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/gcmodule.c,v
retrieving revision 2.15
retrieving revision 2.15.6.1
diff -C2 -d -r2.15 -r2.15.6.1
*** gcmodule.c 2000/10/04 16:34:09 2.15
--- gcmodule.c 2001/11/01 15:34:20 2.15.6.1
***************
*** 44,47 ****
--- 44,50 ----
static int allocated;
+ /* true if we are currently running the collector */
+ static int collecting;
+
/* set for debugging information */
#define DEBUG_STATS (1<<0) /* print collection statistics */
***************
*** 491,496 ****
_PyGC_Insert(PyObject *op)
{
- /* collection lock since collecting may cause allocations */
- static int collecting = 0;
#ifdef Py_DEBUG
--- 494,497 ----
***************
*** 504,510 ****
!collecting &&
!PyErr_Occurred()) {
! collecting++;
collect_generations();
! collecting--;
}
allocated++;
--- 505,511 ----
!collecting &&
!PyErr_Occurred()) {
! collecting = 1;
collect_generations();
! collecting = 0;
}
allocated++;
***************
*** 595,602 ****
return NULL;
! generation = 2;
! gc_list_merge(&generation0, &generation2);
! gc_list_merge(&generation1, &generation2);
! n = collect(&generation2, &generation2);
return Py_BuildValue("l", n);
--- 596,610 ----
return NULL;
! if (collecting) {
! n = 0; /* already collecting, don't do anything */
! }
! else {
! collecting = 1;
! generation = 2;
! gc_list_merge(&generation0, &generation2);
! gc_list_merge(&generation1, &generation2);
! n = collect(&generation2, &generation2);
! collecting = 0;
! }
return Py_BuildValue("l", n);