summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2006-03-10 15:27:16 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:56:56 -0500
commit3baf0606040419988f1a08c0da7f546c5904d8ca (patch)
treeb0a0ea4edce4523b965690f23240d6a284d984f6
parent3d9fc634ef8164a34adf14c0f77473c6268d2538 (diff)
downloadsamba-3baf0606040419988f1a08c0da7f546c5904d8ca.tar.gz
samba-3baf0606040419988f1a08c0da7f546c5904d8ca.tar.bz2
samba-3baf0606040419988f1a08c0da7f546c5904d8ca.zip
r14161: return early if we know the job is already finished
(This used to be commit 09f6f552d73f782dc8d62cefad9c5f584b7b07d2)
-rw-r--r--source4/lib/ldb/ldb_ildap/ldb_ildap.c7
-rw-r--r--source4/lib/ldb/ldb_ldap/ldb_ldap.c10
-rw-r--r--source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c19
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_tdb.c3
4 files changed, 29 insertions, 10 deletions
diff --git a/source4/lib/ldb/ldb_ildap/ldb_ildap.c b/source4/lib/ldb/ldb_ildap/ldb_ildap.c
index f309262a55..ceb9c4aafb 100644
--- a/source4/lib/ldb/ldb_ildap/ldb_ildap.c
+++ b/source4/lib/ldb/ldb_ildap/ldb_ildap.c
@@ -352,6 +352,9 @@ static int ildb_request_send(struct ldb_module *module, struct ldap_message *msg
h->private_data = (void *)ildb_ac;
+ h->state = LDB_ASYNC_INIT;
+ h->status = LDB_SUCCESS;
+
req = ldap_request_send(ildb->ldap, msg);
if (req == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "async send request failed"));
@@ -922,6 +925,10 @@ static int ildb_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_
{
struct ildb_async_context *ac = talloc_get_type(handle->private_data, struct ildb_async_context);
+ if (handle->state == LDB_ASYNC_DONE) {
+ return handle->status;
+ }
+
if (!ac) {
return LDB_ERR_OPERATIONS_ERROR;
}
diff --git a/source4/lib/ldb/ldb_ldap/ldb_ldap.c b/source4/lib/ldb/ldb_ldap/ldb_ldap.c
index 5a4d911218..a2ca7a7cc8 100644
--- a/source4/lib/ldb/ldb_ldap/ldb_ldap.c
+++ b/source4/lib/ldb/ldb_ldap/ldb_ldap.c
@@ -87,6 +87,9 @@ static struct ldb_async_handle *init_handle(struct lldb_private *lldb, struct ld
h->private_data = (void *)ac;
+ h->state = LDB_ASYNC_INIT;
+ h->status = LDB_SUCCESS;
+
ac->module = module;
ac->context = context;
ac->callback = callback;
@@ -885,12 +888,15 @@ static int lldb_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_
LDAPMessage *result;
int ret = LDB_ERR_OPERATIONS_ERROR;
- if (!ac->msgid) {
+ if (handle->state == LDB_ASYNC_DONE) {
+ return handle->status;
+ }
+
+ if (!ac || !ac->msgid) {
return LDB_ERR_OPERATIONS_ERROR;
}
handle->status = LDB_SUCCESS;
- handle->state = LDB_ASYNC_INIT;
switch(type) {
case LDB_WAIT_NONE:
diff --git a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
index d9d9269de4..bcb830c38d 100644
--- a/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
+++ b/source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.c
@@ -57,9 +57,9 @@ struct lsql_async_context {
int (*callback)(struct ldb_context *, void *, struct ldb_async_result *);
};
-static struct ldb_async_handle *init_lsql_handle(struct lsqlite3_private *lsqlite3, struct ldb_module *module,
- void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *))
+static struct ldb_async_handle *init_handle(struct lsqlite3_private *lsqlite3, struct ldb_module *module,
+ void *context,
+ int (*callback)(struct ldb_context *, void *, struct ldb_async_result *))
{
struct lsql_async_context *ac;
struct ldb_async_handle *h;
@@ -81,6 +81,9 @@ static struct ldb_async_handle *init_lsql_handle(struct lsqlite3_private *lsqlit
h->private_data = (void *)ac;
+ h->state = LDB_ASYNC_INIT;
+ h->status = LDB_SUCCESS;
+
ac->module = module;
ac->context = context;
ac->callback = callback;
@@ -899,7 +902,7 @@ int lsql_search_async(struct ldb_module *module, const struct ldb_dn *base,
char *query = NULL;
int ret;
- *handle = init_lsql_handle(lsqlite3, module, context, callback);
+ *handle = init_handle(lsqlite3, module, context, callback);
if (*handle == NULL) {
talloc_free(*handle);
return LDB_ERR_OPERATIONS_ERROR;
@@ -1111,7 +1114,7 @@ static int lsql_add_async(struct ldb_module *module, struct ldb_message *msg,
int i;
int ret = LDB_ERR_OPERATIONS_ERROR;
- *handle = init_lsql_handle(lsqlite3, module, context, callback);
+ *handle = init_handle(lsqlite3, module, context, callback);
if (*handle == NULL) {
goto failed;
}
@@ -1267,7 +1270,7 @@ static int lsql_modify_async(struct ldb_module *module, const struct ldb_message
int i;
int ret = LDB_ERR_OPERATIONS_ERROR;
- *handle = init_lsql_handle(lsqlite3, module, context, callback);
+ *handle = init_handle(lsqlite3, module, context, callback);
if (*handle == NULL) {
goto failed;
}
@@ -1481,7 +1484,7 @@ static int lsql_delete_async(struct ldb_module *module, const struct ldb_dn *dn,
int ret = LDB_ERR_OPERATIONS_ERROR;
- *handle = init_lsql_handle(lsqlite3, module, context, callback);
+ *handle = init_handle(lsqlite3, module, context, callback);
if (*handle == NULL) {
goto failed;
}
@@ -1559,7 +1562,7 @@ static int lsql_rename_async(struct ldb_module *module, const struct ldb_dn *old
char *query;
int ret = LDB_ERR_OPERATIONS_ERROR;
- *handle = init_lsql_handle(lsqlite3, module, context, callback);
+ *handle = init_handle(lsqlite3, module, context, callback);
if (*handle == NULL) {
goto failed;
}
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
index a77553dcb8..bc936eb71e 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
@@ -102,6 +102,9 @@ struct ldb_async_handle *init_ltdb_handle(struct ltdb_private *ltdb, struct ldb_
h->private_data = (void *)ac;
+ h->state = LDB_ASYNC_INIT;
+ h->status = LDB_SUCCESS;
+
ac->module = module;
ac->context = context;
ac->callback = callback;