summaryrefslogtreecommitdiff
path: root/lib/tdb
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-12-18 20:42:50 +0000
committerJelmer Vernooij <jelmer@samba.org>2008-12-18 20:42:50 +0000
commit6fe6983e4c960abc69d5fa80cbef534ae515209a (patch)
tree5b89670c341485e0b721654ec3761358d95862cc /lib/tdb
parent8c1ede0b32fd0974f7161cadf29f13a25210e4ee (diff)
downloadsamba-6fe6983e4c960abc69d5fa80cbef534ae515209a.tar.gz
samba-6fe6983e4c960abc69d5fa80cbef534ae515209a.tar.bz2
samba-6fe6983e4c960abc69d5fa80cbef534ae515209a.zip
Make sure to not close tdb database more than once.
Diffstat (limited to 'lib/tdb')
-rw-r--r--lib/tdb/pytdb.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/tdb/pytdb.c b/lib/tdb/pytdb.c
index d6d0625686..b7087c4bcc 100644
--- a/lib/tdb/pytdb.c
+++ b/lib/tdb/pytdb.c
@@ -34,10 +34,12 @@
#include <signal.h>
#include <tdb.h>
#include <fcntl.h>
+#include <stdbool.h>
typedef struct {
PyObject_HEAD
TDB_CONTEXT *ctx;
+ bool closed;
} PyTdbObject;
PyAPI_DATA(PyTypeObject) PyTdb;
@@ -93,6 +95,7 @@ static PyObject *py_tdb_open(PyTypeObject *type, PyObject *args, PyObject *kwarg
ret = PyObject_New(PyTdbObject, &PyTdb);
ret->ctx = ctx;
+ ret->closed = false;
return (PyObject *)ret;
}
@@ -161,7 +164,11 @@ static PyObject *obj_unlockall_read(PyTdbObject *self)
static PyObject *obj_close(PyTdbObject *self)
{
- int ret = tdb_close(self->ctx);
+ int ret;
+ if (self->closed)
+ return Py_None;
+ ret = tdb_close(self->ctx);
+ self->closed = true;
PyErr_TDB_ERROR_IS_ERR_RAISE(ret, self->ctx);
return Py_None;
}
@@ -395,7 +402,8 @@ static PyObject *tdb_object_repr(PyTdbObject *self)
static void tdb_object_dealloc(PyTdbObject *self)
{
- tdb_close(self->ctx);
+ if (!self->closed)
+ tdb_close(self->ctx);
PyObject_Del(self);
}