Commit 9a37974b authored by Jeremy Hylton's avatar Jeremy Hylton

Two small refcount improvements when deallocating a persistent object.

Decref its reference to the cache.
In a debug build, account for the two bogus additions to _Py_RefTotal.

Also, reindent initcPickleCache().
parent fe5d00f6
......@@ -88,7 +88,7 @@ process must skip such objects, rather than deactivating them.
static char cPickleCache_doc_string[] =
"Defines the PickleCache used by ZODB Connection objects.\n"
"\n"
"$Id: cPickleCache.c,v 1.73 2003/03/31 22:43:42 jeremy Exp $\n";
"$Id: cPickleCache.c,v 1.74 2003/04/01 15:32:28 jeremy Exp $\n";
#define ASSIGN(V,E) {PyObject *__e; __e=(E); Py_XDECREF(V); (V)=__e;}
#define UNLESS(E) if(!(E))
......@@ -501,6 +501,12 @@ cc_oid_unreferenced(ccobject *self, PyObject *oid)
interpreter has untracked the reference. Track it again.
*/
_Py_NewReference(v);
/* Don't increment total refcount as a result of the
shenanigans played in this function. The _Py_NewReference()
call above and the Py_INCREF() below both create artificial
references to v.
*/
_Py_RefTotal -= 2;
/* XXX it may be a problem that v->ob_type is still NULL?
I don't understand what this comment means. --jeremy */
assert(v->ob_type);
......@@ -517,6 +523,7 @@ cc_oid_unreferenced(ccobject *self, PyObject *oid)
/* XXX Should we call _Py_ForgetReference() on error exit? */
if (PyDict_DelItem(self->data, oid) < 0)
return -1;
Py_DECREF((ccobject *)((cPersistentObject *)v)->cache);
if (v->ob_refcnt != 1) {
PyErr_SetString(PyExc_ValueError,
......
......@@ -88,7 +88,7 @@ process must skip such objects, rather than deactivating them.
static char cPickleCache_doc_string[] =
"Defines the PickleCache used by ZODB Connection objects.\n"
"\n"
"$Id: cPickleCache.c,v 1.73 2003/03/31 22:43:42 jeremy Exp $\n";
"$Id: cPickleCache.c,v 1.74 2003/04/01 15:32:28 jeremy Exp $\n";
#define ASSIGN(V,E) {PyObject *__e; __e=(E); Py_XDECREF(V); (V)=__e;}
#define UNLESS(E) if(!(E))
......@@ -501,6 +501,12 @@ cc_oid_unreferenced(ccobject *self, PyObject *oid)
interpreter has untracked the reference. Track it again.
*/
_Py_NewReference(v);
/* Don't increment total refcount as a result of the
shenanigans played in this function. The _Py_NewReference()
call above and the Py_INCREF() below both create artificial
references to v.
*/
_Py_RefTotal -= 2;
/* XXX it may be a problem that v->ob_type is still NULL?
I don't understand what this comment means. --jeremy */
assert(v->ob_type);
......@@ -517,6 +523,7 @@ cc_oid_unreferenced(ccobject *self, PyObject *oid)
/* XXX Should we call _Py_ForgetReference() on error exit? */
if (PyDict_DelItem(self->data, oid) < 0)
return -1;
Py_DECREF((ccobject *)((cPersistentObject *)v)->cache);
if (v->ob_refcnt != 1) {
PyErr_SetString(PyExc_ValueError,
......
......@@ -88,7 +88,7 @@ process must skip such objects, rather than deactivating them.
static char cPickleCache_doc_string[] =
"Defines the PickleCache used by ZODB Connection objects.\n"
"\n"
"$Id: cPickleCache.c,v 1.73 2003/03/31 22:43:42 jeremy Exp $\n";
"$Id: cPickleCache.c,v 1.74 2003/04/01 15:32:28 jeremy Exp $\n";
#define ASSIGN(V,E) {PyObject *__e; __e=(E); Py_XDECREF(V); (V)=__e;}
#define UNLESS(E) if(!(E))
......@@ -501,6 +501,12 @@ cc_oid_unreferenced(ccobject *self, PyObject *oid)
interpreter has untracked the reference. Track it again.
*/
_Py_NewReference(v);
/* Don't increment total refcount as a result of the
shenanigans played in this function. The _Py_NewReference()
call above and the Py_INCREF() below both create artificial
references to v.
*/
_Py_RefTotal -= 2;
/* XXX it may be a problem that v->ob_type is still NULL?
I don't understand what this comment means. --jeremy */
assert(v->ob_type);
......@@ -517,6 +523,7 @@ cc_oid_unreferenced(ccobject *self, PyObject *oid)
/* XXX Should we call _Py_ForgetReference() on error exit? */
if (PyDict_DelItem(self->data, oid) < 0)
return -1;
Py_DECREF((ccobject *)((cPersistentObject *)v)->cache);
if (v->ob_refcnt != 1) {
PyErr_SetString(PyExc_ValueError,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment