Commit e1b9f58c authored by Toby Dickenson's avatar Toby Dickenson

added comments

parent e9424316
...@@ -88,7 +88,7 @@ process must skip such objects, rather than deactivating them. ...@@ -88,7 +88,7 @@ process must skip such objects, rather than deactivating them.
static char cPickleCache_doc_string[] = static char cPickleCache_doc_string[] =
"Defines the PickleCache used by ZODB Connection objects.\n" "Defines the PickleCache used by ZODB Connection objects.\n"
"\n" "\n"
"$Id: cPickleCache.c,v 1.63 2002/04/18 09:18:26 htrd Exp $\n"; "$Id: cPickleCache.c,v 1.64 2002/04/18 09:32:13 htrd Exp $\n";
#define ASSIGN(V,E) {PyObject *__e; __e=(E); Py_XDECREF(V); (V)=__e;} #define ASSIGN(V,E) {PyObject *__e; __e=(E); Py_XDECREF(V); (V)=__e;}
#define UNLESS(E) if(!(E)) #define UNLESS(E) if(!(E))
...@@ -835,6 +835,7 @@ cc_add_item(ccobject *self, PyObject *key, PyObject *v) ...@@ -835,6 +835,7 @@ cc_add_item(ccobject *self, PyObject *key, PyObject *v)
if (jar == NULL) if (jar == NULL)
return -1; return -1;
if (jar==Py_None) { if (jar==Py_None) {
Py_DECREF(jar);
PyErr_SetString(PyExc_ValueError, PyErr_SetString(PyExc_ValueError,
"Cached object jar missing"); "Cached object jar missing");
return -1; return -1;
...@@ -975,11 +976,23 @@ static int ...@@ -975,11 +976,23 @@ static int
_ring_corrupt(ccobject *self, const char *context) _ring_corrupt(ccobject *self, const char *context)
{ {
CPersistentRing *here = &(self->ring_home); CPersistentRing *here = &(self->ring_home);
/* Determine the number of objects we expect to see in the ring.
* Normally this is one for the home node plus one for each
* non-ghost object, for which we maintain a separate total. If the
* ring is unlocked then this value should be precise; there should
* be no foreign nodes in the ring. If locked, it may be an
* underestimate */
int expected = 1 + self->non_ghost_count; int expected = 1 + self->non_ghost_count;
int total = 0; int total = 0;
do { do {
if (++total > (expected + 10)) if (++total > (expected + 10))
return 3; /* ring too big, by a large margin */ /* ring too big, by a large margin. This probably
* means we are stomping through random memory. Abort
* now, and maybe we can deliver this error message
* before dumping core */
return 3;
if (!here->next) if (!here->next)
return 4; /* various linking problems */ return 4; /* various linking problems */
if (!here->prev) if (!here->prev)
...@@ -993,15 +1006,18 @@ _ring_corrupt(ccobject *self, const char *context) ...@@ -993,15 +1006,18 @@ _ring_corrupt(ccobject *self, const char *context)
if (here->next->prev != here) if (here->next->prev != here)
return 10; return 10;
if (!self->ring_lock) { if (!self->ring_lock) {
/* If the ring must be locked, then it only contains /* If the ring is unlocked, then it must not contain
object other than persistent instances. * objects other than persistent instances (and the home) */
*/
if (here != &self->ring_home) { if (here != &self->ring_home) {
cPersistentObject *object = object_from_ring(self, here, cPersistentObject *object = object_from_ring(self, here,
context); context);
if (!object) if (!object)
return 12; return 12;
if (object->state == cPersistent_GHOST_STATE) if (object->state == cPersistent_GHOST_STATE)
/* ghost objects should not be in the ring, according
* to the ghost storage regime. Experience shows
* that this error condition is likely to be caused
* by a race condition bug somewhere */
return 13; return 13;
} }
} }
...@@ -1010,7 +1026,10 @@ _ring_corrupt(ccobject *self, const char *context) ...@@ -1010,7 +1026,10 @@ _ring_corrupt(ccobject *self, const char *context)
if (self->ring_lock) { if (self->ring_lock) {
if (total < expected) if (total < expected)
return 6; /* ring too small; too big is ok when locked */ /* ring is too small.
too big is ok when locked, we have already checked it is
not too big */
return 6;
} else { } else {
if (total != expected) if (total != expected)
return 14; /* ring size wrong, or bad ghost accounting */ return 14; /* ring size wrong, or bad ghost accounting */
......
...@@ -88,7 +88,7 @@ process must skip such objects, rather than deactivating them. ...@@ -88,7 +88,7 @@ process must skip such objects, rather than deactivating them.
static char cPickleCache_doc_string[] = static char cPickleCache_doc_string[] =
"Defines the PickleCache used by ZODB Connection objects.\n" "Defines the PickleCache used by ZODB Connection objects.\n"
"\n" "\n"
"$Id: cPickleCache.c,v 1.63 2002/04/18 09:18:26 htrd Exp $\n"; "$Id: cPickleCache.c,v 1.64 2002/04/18 09:32:13 htrd Exp $\n";
#define ASSIGN(V,E) {PyObject *__e; __e=(E); Py_XDECREF(V); (V)=__e;} #define ASSIGN(V,E) {PyObject *__e; __e=(E); Py_XDECREF(V); (V)=__e;}
#define UNLESS(E) if(!(E)) #define UNLESS(E) if(!(E))
...@@ -835,6 +835,7 @@ cc_add_item(ccobject *self, PyObject *key, PyObject *v) ...@@ -835,6 +835,7 @@ cc_add_item(ccobject *self, PyObject *key, PyObject *v)
if (jar == NULL) if (jar == NULL)
return -1; return -1;
if (jar==Py_None) { if (jar==Py_None) {
Py_DECREF(jar);
PyErr_SetString(PyExc_ValueError, PyErr_SetString(PyExc_ValueError,
"Cached object jar missing"); "Cached object jar missing");
return -1; return -1;
...@@ -975,11 +976,23 @@ static int ...@@ -975,11 +976,23 @@ static int
_ring_corrupt(ccobject *self, const char *context) _ring_corrupt(ccobject *self, const char *context)
{ {
CPersistentRing *here = &(self->ring_home); CPersistentRing *here = &(self->ring_home);
/* Determine the number of objects we expect to see in the ring.
* Normally this is one for the home node plus one for each
* non-ghost object, for which we maintain a separate total. If the
* ring is unlocked then this value should be precise; there should
* be no foreign nodes in the ring. If locked, it may be an
* underestimate */
int expected = 1 + self->non_ghost_count; int expected = 1 + self->non_ghost_count;
int total = 0; int total = 0;
do { do {
if (++total > (expected + 10)) if (++total > (expected + 10))
return 3; /* ring too big, by a large margin */ /* ring too big, by a large margin. This probably
* means we are stomping through random memory. Abort
* now, and maybe we can deliver this error message
* before dumping core */
return 3;
if (!here->next) if (!here->next)
return 4; /* various linking problems */ return 4; /* various linking problems */
if (!here->prev) if (!here->prev)
...@@ -993,15 +1006,18 @@ _ring_corrupt(ccobject *self, const char *context) ...@@ -993,15 +1006,18 @@ _ring_corrupt(ccobject *self, const char *context)
if (here->next->prev != here) if (here->next->prev != here)
return 10; return 10;
if (!self->ring_lock) { if (!self->ring_lock) {
/* If the ring must be locked, then it only contains /* If the ring is unlocked, then it must not contain
object other than persistent instances. * objects other than persistent instances (and the home) */
*/
if (here != &self->ring_home) { if (here != &self->ring_home) {
cPersistentObject *object = object_from_ring(self, here, cPersistentObject *object = object_from_ring(self, here,
context); context);
if (!object) if (!object)
return 12; return 12;
if (object->state == cPersistent_GHOST_STATE) if (object->state == cPersistent_GHOST_STATE)
/* ghost objects should not be in the ring, according
* to the ghost storage regime. Experience shows
* that this error condition is likely to be caused
* by a race condition bug somewhere */
return 13; return 13;
} }
} }
...@@ -1010,7 +1026,10 @@ _ring_corrupt(ccobject *self, const char *context) ...@@ -1010,7 +1026,10 @@ _ring_corrupt(ccobject *self, const char *context)
if (self->ring_lock) { if (self->ring_lock) {
if (total < expected) if (total < expected)
return 6; /* ring too small; too big is ok when locked */ /* ring is too small.
too big is ok when locked, we have already checked it is
not too big */
return 6;
} else { } else {
if (total != expected) if (total != expected)
return 14; /* ring size wrong, or bad ghost accounting */ return 14; /* ring size wrong, or bad ghost accounting */
......
...@@ -88,7 +88,7 @@ process must skip such objects, rather than deactivating them. ...@@ -88,7 +88,7 @@ process must skip such objects, rather than deactivating them.
static char cPickleCache_doc_string[] = static char cPickleCache_doc_string[] =
"Defines the PickleCache used by ZODB Connection objects.\n" "Defines the PickleCache used by ZODB Connection objects.\n"
"\n" "\n"
"$Id: cPickleCache.c,v 1.63 2002/04/18 09:18:26 htrd Exp $\n"; "$Id: cPickleCache.c,v 1.64 2002/04/18 09:32:13 htrd Exp $\n";
#define ASSIGN(V,E) {PyObject *__e; __e=(E); Py_XDECREF(V); (V)=__e;} #define ASSIGN(V,E) {PyObject *__e; __e=(E); Py_XDECREF(V); (V)=__e;}
#define UNLESS(E) if(!(E)) #define UNLESS(E) if(!(E))
...@@ -835,6 +835,7 @@ cc_add_item(ccobject *self, PyObject *key, PyObject *v) ...@@ -835,6 +835,7 @@ cc_add_item(ccobject *self, PyObject *key, PyObject *v)
if (jar == NULL) if (jar == NULL)
return -1; return -1;
if (jar==Py_None) { if (jar==Py_None) {
Py_DECREF(jar);
PyErr_SetString(PyExc_ValueError, PyErr_SetString(PyExc_ValueError,
"Cached object jar missing"); "Cached object jar missing");
return -1; return -1;
...@@ -975,11 +976,23 @@ static int ...@@ -975,11 +976,23 @@ static int
_ring_corrupt(ccobject *self, const char *context) _ring_corrupt(ccobject *self, const char *context)
{ {
CPersistentRing *here = &(self->ring_home); CPersistentRing *here = &(self->ring_home);
/* Determine the number of objects we expect to see in the ring.
* Normally this is one for the home node plus one for each
* non-ghost object, for which we maintain a separate total. If the
* ring is unlocked then this value should be precise; there should
* be no foreign nodes in the ring. If locked, it may be an
* underestimate */
int expected = 1 + self->non_ghost_count; int expected = 1 + self->non_ghost_count;
int total = 0; int total = 0;
do { do {
if (++total > (expected + 10)) if (++total > (expected + 10))
return 3; /* ring too big, by a large margin */ /* ring too big, by a large margin. This probably
* means we are stomping through random memory. Abort
* now, and maybe we can deliver this error message
* before dumping core */
return 3;
if (!here->next) if (!here->next)
return 4; /* various linking problems */ return 4; /* various linking problems */
if (!here->prev) if (!here->prev)
...@@ -993,15 +1006,18 @@ _ring_corrupt(ccobject *self, const char *context) ...@@ -993,15 +1006,18 @@ _ring_corrupt(ccobject *self, const char *context)
if (here->next->prev != here) if (here->next->prev != here)
return 10; return 10;
if (!self->ring_lock) { if (!self->ring_lock) {
/* If the ring must be locked, then it only contains /* If the ring is unlocked, then it must not contain
object other than persistent instances. * objects other than persistent instances (and the home) */
*/
if (here != &self->ring_home) { if (here != &self->ring_home) {
cPersistentObject *object = object_from_ring(self, here, cPersistentObject *object = object_from_ring(self, here,
context); context);
if (!object) if (!object)
return 12; return 12;
if (object->state == cPersistent_GHOST_STATE) if (object->state == cPersistent_GHOST_STATE)
/* ghost objects should not be in the ring, according
* to the ghost storage regime. Experience shows
* that this error condition is likely to be caused
* by a race condition bug somewhere */
return 13; return 13;
} }
} }
...@@ -1010,7 +1026,10 @@ _ring_corrupt(ccobject *self, const char *context) ...@@ -1010,7 +1026,10 @@ _ring_corrupt(ccobject *self, const char *context)
if (self->ring_lock) { if (self->ring_lock) {
if (total < expected) if (total < expected)
return 6; /* ring too small; too big is ok when locked */ /* ring is too small.
too big is ok when locked, we have already checked it is
not too big */
return 6;
} else { } else {
if (total != expected) if (total != expected)
return 14; /* ring size wrong, or bad ghost accounting */ return 14; /* ring size wrong, or bad ghost accounting */
......
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