[Zodb-checkins] CVS: ZODB4/src/persistence - persistence.c:1.13

Phillip J. Eby pje at telecommunity.com
Thu Apr 17 15:39:24 EDT 2003


Update of /cvs-repository/ZODB4/src/persistence
In directory cvs.zope.org:/tmp/cvs-serv1443/src/persistence

Modified Files:
	persistence.c 
Log Message:
Fix object state change bugs reported in Zope3 collector #107.  In the
presence of a broken DM 'setstate()' or 'register()' method, persistent
objects could end up in CHANGED state when they should have stayed in their
original state.  This is perhaps not a complete solution to the issue of
what an object's state should be in the presence of a failure, but it 
prevents the two current "silent failure" conditions where an object thinks
it's CHANGED, but is not actually registered with the DM.  Added test cases
to demonstrate the old behavior and ensure it doesn't come back.


=== ZODB4/src/persistence/persistence.c 1.12 => 1.13 ===
--- ZODB4/src/persistence/persistence.c:1.12	Fri Apr 11 17:59:54 2003
+++ ZODB4/src/persistence/persistence.c	Thu Apr 17 14:38:53 2003
@@ -59,9 +59,9 @@
     result = PyObject_Call(meth, arg, NULL);
     Py_DECREF(arg);
     Py_DECREF(meth);
+    if (result) {
     if (self->po_state == UPTODATE || self->po_state == STICKY)
 	self->po_state = CHANGED;
-    if (result) {
 	Py_DECREF(result);
 	return 1;
     }
@@ -306,7 +306,7 @@
 	    /* Turn a ghost into a real object. */
 	    self->po_state = CHANGED;
 	    if (!_PyPersist_Load((PyPersistObject *)self))
-		return -1;
+		{ self->po_state = GHOST; return -1; }
 	    if (newstate == CHANGED_TRUE)
 		self->po_state = CHANGED;
 	    else
@@ -315,9 +315,9 @@
     } else if (newstate == CHANGED_TRUE) {
 	/* Mark an up-to-date object as changed. */
 	if (self->po_state == UPTODATE) {
-	    self->po_state = CHANGED;
 	    if (!_PyPersist_RegisterDataManager((PyPersistObject *)self))
 		return -1;
+	    self->po_state = CHANGED;
 	}
     } else if (newstate == CHANGED_FALSE) {
 	/* Mark a changed object as up-to-date, but do nothing if it's




More information about the Zodb-checkins mailing list