Author: idra Date: 2006-03-10 15:27:16 +0000 (Fri, 10 Mar 2006) New Revision: 14161
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=14161 Log: return early if we know the job is already finished Modified: branches/SAMBA_4_0/source/lib/ldb/ldb_ildap/ldb_ildap.c branches/SAMBA_4_0/source/lib/ldb/ldb_ldap/ldb_ldap.c branches/SAMBA_4_0/source/lib/ldb/ldb_sqlite3/ldb_sqlite3.c branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c Changeset: Modified: branches/SAMBA_4_0/source/lib/ldb/ldb_ildap/ldb_ildap.c =================================================================== --- branches/SAMBA_4_0/source/lib/ldb/ldb_ildap/ldb_ildap.c 2006-03-10 15:10:47 UTC (rev 14160) +++ branches/SAMBA_4_0/source/lib/ldb/ldb_ildap/ldb_ildap.c 2006-03-10 15:27:16 UTC (rev 14161) @@ -352,6 +352,9 @@ 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 @@ { 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; } Modified: branches/SAMBA_4_0/source/lib/ldb/ldb_ldap/ldb_ldap.c =================================================================== --- branches/SAMBA_4_0/source/lib/ldb/ldb_ldap/ldb_ldap.c 2006-03-10 15:10:47 UTC (rev 14160) +++ branches/SAMBA_4_0/source/lib/ldb/ldb_ldap/ldb_ldap.c 2006-03-10 15:27:16 UTC (rev 14161) @@ -87,6 +87,9 @@ 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 @@ 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: Modified: branches/SAMBA_4_0/source/lib/ldb/ldb_sqlite3/ldb_sqlite3.c =================================================================== --- branches/SAMBA_4_0/source/lib/ldb/ldb_sqlite3/ldb_sqlite3.c 2006-03-10 15:10:47 UTC (rev 14160) +++ branches/SAMBA_4_0/source/lib/ldb/ldb_sqlite3/ldb_sqlite3.c 2006-03-10 15:27:16 UTC (rev 14161) @@ -57,9 +57,9 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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; } Modified: branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c =================================================================== --- branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c 2006-03-10 15:10:47 UTC (rev 14160) +++ branches/SAMBA_4_0/source/lib/ldb/ldb_tdb/ldb_tdb.c 2006-03-10 15:27:16 UTC (rev 14161) @@ -102,6 +102,9 @@ h->private_data = (void *)ac; + h->state = LDB_ASYNC_INIT; + h->status = LDB_SUCCESS; + ac->module = module; ac->context = context; ac->callback = callback;
