summaryrefslogtreecommitdiff
path: root/source4/lib/db_wrap.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-07-20 00:59:38 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:29:45 -0500
commit338c3f8523d5db2cba1b79f94ff0cecabcd9e9cd (patch)
tree9cbd8fa10fbb46b70fe1a2783bc30689f3d652ba /source4/lib/db_wrap.c
parentf650ea10120d41ceff8ea04975fea7637cb45a0a (diff)
downloadsamba-338c3f8523d5db2cba1b79f94ff0cecabcd9e9cd.tar.gz
samba-338c3f8523d5db2cba1b79f94ff0cecabcd9e9cd.tar.bz2
samba-338c3f8523d5db2cba1b79f94ff0cecabcd9e9cd.zip
r8625: move the ldb_wrap logic into the ldb code. This logic is meant to
avoid the horrors of posix locking, but it was preventing us having an ldb open twice with different options. Now each ldb open of the same file shares the same underlying tdb, but uses a different ldb structure (This used to be commit 4e090c66dfa1d2764e4693578d3845be3b8893f6)
Diffstat (limited to 'source4/lib/db_wrap.c')
-rw-r--r--source4/lib/db_wrap.c37
1 files changed, 1 insertions, 36 deletions
diff --git a/source4/lib/db_wrap.c b/source4/lib/db_wrap.c
index 57055462ff..8698e9affd 100644
--- a/source4/lib/db_wrap.c
+++ b/source4/lib/db_wrap.c
@@ -33,14 +33,6 @@
#include "lib/ldb/include/ldb.h"
#include "db_wrap.h"
-struct ldb_wrap {
- struct ldb_context *ldb;
-
- const char *url;
- struct ldb_wrap *next, *prev;
-};
-
-static struct ldb_wrap *ldb_list;
static struct tdb_wrap *tdb_list;
/*
@@ -62,14 +54,6 @@ static void ldb_wrap_debug(void *context, enum ldb_debug_level level,
free(s);
}
-/* destroy the last connection to a ldb */
-static int ldb_wrap_destructor(void *ctx)
-{
- struct ldb_wrap *w = ctx;
- DLIST_REMOVE(ldb_list, w);
- return 0;
-}
-
/*
wrapped connection to a ldb database
to close just talloc_free() the returned ldb_context
@@ -80,18 +64,11 @@ struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx,
const char *options[])
{
struct ldb_context *ldb;
- struct ldb_wrap *w;
int ret;
struct event_context *ev;
char *real_url = NULL;
- for (w = ldb_list; w; w = w->next) {
- if (strcmp(url, w->url) == 0) {
- return talloc_reference(mem_ctx, w->ldb);
- }
- }
-
- ldb = ldb_init(talloc_autofree_context());
+ ldb = ldb_init(mem_ctx);
if (ldb == NULL) {
return NULL;
}
@@ -126,20 +103,8 @@ struct ldb_context *ldb_wrap_connect(TALLOC_CTX *mem_ctx,
talloc_free(real_url);
- w = talloc(ldb, struct ldb_wrap);
- if (w == NULL) {
- talloc_free(ldb);
- return NULL;
- }
-
- w->ldb = ldb;
- w->url = talloc_strdup(w, url);
-
- talloc_set_destructor(w, ldb_wrap_destructor);
ldb_set_debug(ldb, ldb_wrap_debug, NULL);
- DLIST_ADD(ldb_list, w);
-
return ldb;
}