[Zodb-checkins] CVS: ZODB3/ZODB - cPickleCache.c:1.78

Jeremy Hylton jeremy@zope.com
Tue, 1 Apr 2003 13:44:25 -0500


Update of /cvs-repository/ZODB3/ZODB
In directory cvs.zope.org:/tmp/cvs-serv28749

Modified Files:
	cPickleCache.c 
Log Message:
Fix one more (last?) refcount problem with the cache.


=== ZODB3/ZODB/cPickleCache.c 1.77 => 1.78 ===
--- ZODB3/ZODB/cPickleCache.c:1.77	Tue Apr  1 11:17:50 2003
+++ ZODB3/ZODB/cPickleCache.c	Tue Apr  1 13:44:25 2003
@@ -506,7 +506,7 @@
     Py_INCREF(v);
 
     /* XXX Should we call _Py_ForgetReference() on error exit? */
-    if (PyDict_DelItem(self->data, oid) < 0)
+    if (PyDict_DelItem(self->data, oid) < 0) 
 	return -1;
     Py_DECREF((ccobject *)((cPersistentObject *)v)->cache);
 
@@ -648,6 +648,7 @@
 static int
 cc_length(ccobject *self)
 {
+    fprintf(stderr, "non_ghost_count = %d\n", self->non_ghost_count);
     return PyObject_Length(self->data);
 }
   
@@ -762,6 +763,9 @@
     
     if (PyDict_SetItem(self->data, key, v) < 0) 
 	return -1;
+    /* Remove the reference used by the dict.  The cache should only
+       have borrowed references to objects. */
+    Py_DECREF(v);
     
     p = (cPersistentObject *)v;
     Py_INCREF(self);
@@ -774,12 +778,7 @@
 	p->ring.prev =  self->ring_home.prev;
 	self->ring_home.prev->next = &p->ring;
 	self->ring_home.prev = &p->ring;
-    } else {
-	/* steal a reference from the dictionary; 
-	   ghosts have a weak reference */
-	Py_DECREF(v);
     }
-    
     return 0;
 }