[Zope-Checkins] CVS: ZODB3/Persistence - cPickleCache.c:1.85.8.10 cPersistence.h:1.25.122.5 cPersistence.c:1.72.8.23
Jeremy Hylton
jeremy@zope.com
Tue, 8 Jul 2003 15:45:33 -0400
Update of /cvs-repository/ZODB3/Persistence
In directory cvs.zope.org:/tmp/cvs-serv10445/Persistence
Modified Files:
Tag: zodb33-devel-branch
cPickleCache.c cPersistence.h cPersistence.c
Log Message:
Remove deallocated() function and change percachedel() to void.
The deallocated() function was exported via PER_DEL(), but no one used
the PER_DEL macro. It's not clear what it's use would be, but using
tp_base should probably be sufficient. As a result, inline the code
in deallocated in Per_dealloc().
Change cc_oid_unreferenced() to be a void function, since no caller
can be prepared to deal with a failure.
=== ZODB3/Persistence/cPickleCache.c 1.85.8.9 => 1.85.8.10 ===
--- ZODB3/Persistence/cPickleCache.c:1.85.8.9 Tue Jul 8 15:27:41 2003
+++ ZODB3/Persistence/cPickleCache.c Tue Jul 8 15:45:28 2003
@@ -440,7 +440,7 @@
return l;
}
-static int
+static void
cc_oid_unreferenced(ccobject *self, PyObject *oid)
{
/* This is called by the persistent object deallocation function
@@ -454,14 +454,10 @@
/* If the cache has been cleared by GC, data will be NULL. */
if (!self->data)
- return 0;
+ return;
v = PyDict_GetItem(self->data, oid);
- if (v == NULL) {
- PyErr_SetObject(PyExc_KeyError, oid);
- return -1;
- }
-
+ assert(v);
assert(v->ob_refcnt == 0);
/* Need to be very hairy here because a dictionary is about
to decref an already deleted object.
@@ -490,15 +486,11 @@
/* XXX Should we call _Py_ForgetReference() on error exit? */
if (PyDict_DelItem(self->data, oid) < 0)
- return -1;
+ return;
Py_DECREF((ccobject *)((cPersistentObject *)v)->cache);
((cPersistentObject *)v)->cache = NULL;
- if (v->ob_refcnt != 1) {
- PyErr_SetString(PyExc_ValueError,
- "refcount is not 1 after removal from dict");
- return -1;
- }
+ assert(v->ob_refcnt == 1);
/* Undo the temporary resurrection.
Don't DECREF the object, because this function is called from
@@ -506,8 +498,6 @@
will all be invoked recursively.
*/
_Py_ForgetReference(v);
-
- return 0;
}
static PyObject *
@@ -686,6 +676,7 @@
VISIT(o);
here = here->next;
}
+#undef VISIT
return 0;
}
=== ZODB3/Persistence/cPersistence.h 1.25.122.4 => 1.25.122.5 ===
--- ZODB3/Persistence/cPersistence.h:1.25.122.4 Thu Jul 3 17:39:09 2003
+++ ZODB3/Persistence/cPersistence.h Tue Jul 8 15:45:28 2003
@@ -52,7 +52,7 @@
cPersistent_HEAD
} cPersistentObject;
-typedef int (*percachedelfunc)(PerCache *, PyObject *);
+typedef void (*percachedelfunc)(PerCache *, PyObject *);
typedef struct {
PyTypeObject *pertype;
@@ -61,7 +61,6 @@
int (*changed)(cPersistentObject*);
void (*accessed)(cPersistentObject*);
void (*ghostify)(cPersistentObject*);
- void (*deallocated)(cPersistentObject*);
int (*setstate)(PyObject*);
percachedelfunc percachedel;
} cPersistenceCAPIstruct;
@@ -83,8 +82,6 @@
#define PER_ALLOW_DEACTIVATION(O) ((O)->state==cPersistent_STICKY_STATE && ((O)->state=cPersistent_UPTODATE_STATE))
#define PER_PREVENT_DEACTIVATION(O) ((O)->state==cPersistent_UPTODATE_STATE && ((O)->state=cPersistent_STICKY_STATE))
-
-#define PER_DEL(O) (cPersistenceCAPI->deallocated((cPersistentObject*)(O)))
#define PER_USE(O) \
(((O)->state != cPersistent_GHOST_STATE \
=== ZODB3/Persistence/cPersistence.c 1.72.8.22 => 1.72.8.23 ===
--- ZODB3/Persistence/cPersistence.c:1.72.8.22 Tue Jul 8 15:27:42 2003
+++ ZODB3/Persistence/cPersistence.c Tue Jul 8 15:45:28 2003
@@ -173,24 +173,6 @@
Py_DECREF(self);
}
-static void
-deallocated(cPersistentObject *self)
-{
- if (self->state >= 0)
- 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);
- assert(status >= 0);
- }
- /* If the object is being deallocated via GC, the percachedel call
- will not release the object's reference to the cache.
- */
- Py_XDECREF(self->cache);
- Py_XDECREF(self->jar);
- Py_XDECREF(self->oid);
-}
-
static int
changed(cPersistentObject *self)
{
@@ -424,7 +406,13 @@
static void
Per_dealloc(cPersistentObject *self)
{
- deallocated(self);
+ if (self->state >= 0)
+ unlink_from_ring(self);
+ if (self->cache)
+ cPersistenceCAPI->percachedel(self->cache, self->oid);
+ Py_XDECREF(self->cache);
+ Py_XDECREF(self->jar);
+ Py_XDECREF(self->oid);
self->ob_type->tp_free(self);
}
@@ -847,7 +835,6 @@
changed,
accessed,
ghostify,
- deallocated,
(intfunctionwithpythonarg)Per_setstate,
NULL /* The percachedel slot is initialized in cPickleCache.c when
the module is loaded. It uses a function in a different