summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/common/ldb.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/ldb/common/ldb.c')
-rw-r--r--source4/lib/ldb/common/ldb.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c
index b51c288993..bfce12bdd3 100644
--- a/source4/lib/ldb/common/ldb.c
+++ b/source4/lib/ldb/common/ldb.c
@@ -1,13 +1,13 @@
-/*
+/*
ldb database library
Copyright (C) Andrew Tridgell 2004
- Copyright (C) Simo Sorce 2005-2006
+ Copyright (C) Simo Sorce 2005-2008
** NOTE! The following LGPL license applies to the ldb
** library. This does NOT imply that all of Samba is released
** under the LGPL
-
+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
@@ -34,15 +34,21 @@
#include "ldb_includes.h"
-/*
+/*
initialise a ldb context
- The mem_ctx is optional
+ The mem_ctx is required
+ The event_ctx is required
*/
-struct ldb_context *ldb_init(void *mem_ctx)
+struct ldb_context *ldb_init(TALLOC_CTX *mem_ctx, struct event_context *ev_ctx)
{
- struct ldb_context *ldb = talloc_zero(mem_ctx, struct ldb_context);
+ struct ldb_context *ldb;
int ret;
+ ldb = talloc_zero(mem_ctx, struct ldb_context);
+ if (ev_ctx == NULL) {
+ ev_ctx = event_context_init(ldb);
+ }
+
ret = ldb_setup_wellknown_attributes(ldb);
if (ret != 0) {
talloc_free(ldb);
@@ -52,6 +58,10 @@ struct ldb_context *ldb_init(void *mem_ctx)
ldb_set_utf8_default(ldb);
ldb_set_create_perms(ldb, 0666);
ldb_set_modules_dir(ldb, LDB_MODULESDIR);
+ ldb_set_event_context(ldb, ev_ctx);
+
+ /* TODO: get timeout from options if available there */
+ ldb->default_timeout = 300; /* set default to 5 minutes */
return ldb;
}
@@ -568,6 +578,16 @@ void ldb_set_create_perms(struct ldb_context *ldb, unsigned int perms)
ldb->create_perms = perms;
}
+void ldb_set_event_context(struct ldb_context *ldb, struct event_context *ev)
+{
+ ldb->ev_ctx = ev;
+}
+
+struct event_context * ldb_get_event_context(struct ldb_context *ldb)
+{
+ return ldb->ev_ctx;
+}
+
/*
start an ldb request
NOTE: the request must be a talloc context.