Commit 40886305 authored by Tim Peters's avatar Tim Peters

TimeStamp_laterThan(): This leaked a Python string object whenever it

had to create a new timestamp.  Fixed.

check2ZODBThreads(), check7ZODBThreads():  Close the database when
these tests end.  Else they leak bigtime, obscuring searches for real
leaks.
parent 977d983f
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
static char TimeStamp_module_documentation[] = static char TimeStamp_module_documentation[] =
"Defines 64-bit TimeStamp objects used as ZODB serial numbers.\n" "Defines 64-bit TimeStamp objects used as ZODB serial numbers.\n"
"\n" "\n"
"\n$Id: TimeStamp.c,v 1.17 2002/11/13 16:32:03 jeremy Exp $\n"; "\n$Id: TimeStamp.c,v 1.18 2003/06/19 21:50:13 tim_one Exp $\n";
#ifdef USE_EXTENSION_CLASS #ifdef USE_EXTENSION_CLASS
#include "ExtensionClass.h" #include "ExtensionClass.h"
...@@ -222,7 +222,7 @@ static PyObject * ...@@ -222,7 +222,7 @@ static PyObject *
TimeStamp_laterThan(TimeStamp *self, PyObject *args) TimeStamp_laterThan(TimeStamp *self, PyObject *args)
{ {
TimeStamp *o=NULL; TimeStamp *o=NULL;
unsigned char *s; unsigned char s[8];
PyObject *a; PyObject *a;
int i; int i;
...@@ -236,9 +236,7 @@ TimeStamp_laterThan(TimeStamp *self, PyObject *args) ...@@ -236,9 +236,7 @@ TimeStamp_laterThan(TimeStamp *self, PyObject *args)
self=o; self=o;
UNLESS(a=PyString_FromStringAndSize((char *) self->data, 8)) return NULL; memcpy(s, self->data, 8);
s=(unsigned char *)PyString_AsString(a);
for (i=7; i > 3; i--) for (i=7; i > 3; i--)
{ {
if (s[i] == 255) if (s[i] == 255)
...@@ -246,7 +244,8 @@ TimeStamp_laterThan(TimeStamp *self, PyObject *args) ...@@ -246,7 +244,8 @@ TimeStamp_laterThan(TimeStamp *self, PyObject *args)
else else
{ {
s[i]++; s[i]++;
return PyObject_CallFunction(OBJECT(self->ob_type), "O", a); return PyObject_CallFunction(OBJECT(self->ob_type), "N",
PyString_FromStringAndSize(s, 8));
} }
} }
......
...@@ -211,10 +211,12 @@ class MTStorage: ...@@ -211,10 +211,12 @@ class MTStorage:
def check2ZODBThreads(self): def check2ZODBThreads(self):
db = ZODB.DB(self._storage) db = ZODB.DB(self._storage)
self._checkNThreads(2, ZODBClientThread, db, self) self._checkNThreads(2, ZODBClientThread, db, self)
db.close()
def check7ZODBThreads(self): def check7ZODBThreads(self):
db = ZODB.DB(self._storage) db = ZODB.DB(self._storage)
self._checkNThreads(7, ZODBClientThread, db, self) self._checkNThreads(7, ZODBClientThread, db, self)
db.close()
def check2StorageThreads(self): def check2StorageThreads(self):
self._checkNThreads(2, StorageClientThread, self._storage, self) self._checkNThreads(2, StorageClientThread, self._storage, self)
......
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