[Zodb-checkins] CVS: ZODB3/Persistence - cPickleCache.c:1.85.8.9 cPersistence.c:1.72.8.22

Jeremy Hylton jeremy at zope.com
Tue Jul 8 16:27:49 EDT 2003


Update of /cvs-repository/ZODB3/Persistence
In directory cvs.zope.org:/tmp/cvs-serv7872

Modified Files:
      Tag: zodb33-devel-branch
	cPickleCache.c cPersistence.c 
Log Message:
Change cc_oid_unreferenced() to set cache to NULL after DECREF.
The caller can't be sure that cc_oid_unreferenced() aka percachedel
will DECREF the cache pointer.  So the caller does an XDECREF.

Also, don't call ghostify() from deallocated() for a non-ghost.  If
we're already getting deallocated, it doesn't make sense to DECREF
ourselves at the end.


=== ZODB3/Persistence/cPickleCache.c 1.85.8.8 => 1.85.8.9 ===
--- ZODB3/Persistence/cPickleCache.c:1.85.8.8	Tue Jul  8 14:19:45 2003
+++ ZODB3/Persistence/cPickleCache.c	Tue Jul  8 15:27:41 2003
@@ -492,6 +492,7 @@
     if (PyDict_DelItem(self->data, oid) < 0) 
 	return -1;
     Py_DECREF((ccobject *)((cPersistentObject *)v)->cache);
+    ((cPersistentObject *)v)->cache = NULL;
 
     if (v->ob_refcnt != 1) {
         PyErr_SetString(PyExc_ValueError,
@@ -850,7 +851,7 @@
 	    /* The DelItem below will account for the reference
 	       held by the list. */
 	} else {
-	    /* This is a ghost object, so we havent kept a reference
+	    /* This is a ghost object, so we haven't kept a reference
 	       count on it.  For it have stayed alive this long
 	       someone else must be keeping a reference to
 	       it. Therefore we need to temporarily give it back a


=== ZODB3/Persistence/cPersistence.c 1.72.8.21 => 1.72.8.22 ===
--- ZODB3/Persistence/cPersistence.c:1.72.8.21	Tue Jul  8 15:23:43 2003
+++ ZODB3/Persistence/cPersistence.c	Tue Jul  8 15:27:42 2003
@@ -123,20 +123,8 @@
 }
 
 static void
-ghostify(cPersistentObject *self)
+unlink_from_ring(cPersistentObject *self)
 {
-    PyObject **dictptr;
-
-    /* are we already a ghost? */
-    if (self->state == cPersistent_GHOST_STATE)
-        return;
-
-    /* XXX is it ever possible to not have a cache? */
-    if (self->cache == NULL) {
-        self->state = cPersistent_GHOST_STATE;
-        return;
-    }
-
     /* If the cache has been cleared, then a non-ghost object
        isn't in the ring any longer.
     */
@@ -151,6 +139,24 @@
     self->ring.prev->next = self->ring.next;
     self->ring.prev = NULL;
     self->ring.next = NULL;
+}
+
+static void
+ghostify(cPersistentObject *self)
+{
+    PyObject **dictptr;
+
+    /* are we already a ghost? */
+    if (self->state == cPersistent_GHOST_STATE)
+        return;
+
+    /* XXX is it ever possible to not have a cache? */
+    if (self->cache == NULL) {
+        self->state = cPersistent_GHOST_STATE;
+        return;
+    }
+
+    unlink_from_ring(self);
     self->state = cPersistent_GHOST_STATE;
     dictptr = _PyObject_GetDictPtr((PyObject *)self);
     if (dictptr && *dictptr) {
@@ -171,7 +177,7 @@
 deallocated(cPersistentObject *self)
 {
     if (self->state >= 0) 
-	ghostify(self);
+	unlink_from_ring(self);
     if (self->cache) {
 	/* XXX Not sure if it ever makes sense for this function to fail. */
 	int status = cPersistenceCAPI->percachedel(self->cache, self->oid);




More information about the Zodb-checkins mailing list