r13827: Minor enhancements or cosmetic changes
authorSimo Sorce <idra@samba.org>
Fri, 3 Mar 2006 22:52:57 +0000 (22:52 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:52:14 +0000 (13:52 -0500)
(This used to be commit 7ef63abae12f65835a82f9931ad1f5ea75e5f3f6)

source4/lib/ldb/ldb_ildap/ldb_ildap.c
source4/lib/ldb/ldb_ldap/ldb_ldap.c
source4/lib/ldb/ldb_tdb/ldb_search.c
source4/lib/ldb/ldb_tdb/ldb_tdb.c
source4/lib/ldb/ldb_tdb/ldb_tdb.h

index 869aec01cdb94ab361fca7be2946b3d18120245b..3467e65bf9f3bdf5d0f0180726b3d117fee5b914 100644 (file)
@@ -536,12 +536,15 @@ static int ildb_search_bytree(struct ldb_module *module, const struct ldb_dn *ba
        ret = ildb_search_async(module, base, scope, tree, attrs, control_req,
                                res, &ildb_search_sync_callback, ildb->ldap->timeout, &handle);
 
-       if (ret != LDB_SUCCESS)
-               return ret;
+       if (ret == LDB_SUCCESS) {
+               ret = ldb_async_wait(module->ldb, handle, LDB_WAIT_ALL);
+               talloc_free(handle);
+       }
 
-       ret = ldb_async_wait(module->ldb, handle, LDB_WAIT_ALL);
+       if (ret != LDB_SUCCESS) {
+               talloc_free(*res);
+       }
 
-       talloc_free(handle);
        return ret;
 }
 
index 031fd847e36a963618b611b58c5b3aae3f1433d3..d671afb953cfc636e2d4c26cc1eb337fbbae37ac 100644 (file)
@@ -395,12 +395,15 @@ static int lldb_search_bytree(struct ldb_module *module, const struct ldb_dn *ba
        ret = lldb_search_async(module, base, scope, tree, attrs, control_req,
                                res, &lldb_search_sync_callback, lldb->timeout, &handle);
 
-       if (ret != LDB_SUCCESS)
-               return ret;
+       if (ret == LDB_SUCCESS) {
+               ret = ldb_async_wait(module->ldb, handle, LDB_WAIT_ALL);
+               talloc_free(handle);
+       }
 
-       ret = ldb_async_wait(module->ldb, handle, LDB_WAIT_ALL);
+       if (ret != LDB_SUCCESS) {
+               talloc_free(*res);
+       }
 
-       talloc_free(handle);
        return ret;
 }
 
@@ -866,7 +869,7 @@ static int lldb_async_wait(struct ldb_module *module, struct ldb_async_handle *h
        struct lldb_private *lldb = talloc_get_type(ac->module->private_data, struct lldb_private);
        struct timeval timeout;
        LDAPMessage *result;
-       int ret;
+       int ret = LDB_ERR_OPERATIONS_ERROR;
 
        if (!ac->msgid) {
                return LDB_ERR_OPERATIONS_ERROR;
@@ -915,8 +918,6 @@ static int lldb_async_wait(struct ldb_module *module, struct ldb_async_handle *h
                        }
                }
                break;
-       default:
-               ret = LDB_ERR_OPERATIONS_ERROR;
        }
 
        return ret;
index 5ffd45aa3b71b347fd9841a767b9cf1be990f145..515503105504c5f3dde0819c05ebc125f21d119e 100644 (file)
@@ -522,7 +522,6 @@ int ltdb_search_async(struct ldb_module *module, const struct ldb_dn *base,
                      const char * const *attrs,
                      void *context,
                      int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
-                     int timeout,
                      struct ldb_async_handle **handle)
 {
        struct ltdb_private *ltdb = talloc_get_type(module->private_data, struct ltdb_private);
@@ -547,7 +546,7 @@ int ltdb_search_async(struct ldb_module *module, const struct ldb_dn *base,
                return LDB_ERR_OPERATIONS_ERROR;
        }
 
-       *handle = init_ltdb_handle(ltdb, module, context, callback, timeout);
+       *handle = init_ltdb_handle(ltdb, module, context, callback);
        if (*handle == NULL) {
                talloc_free(*handle);
                ltdb_unlock_read(module);
@@ -594,14 +593,17 @@ int ltdb_search_bytree(struct ldb_module *module, const struct ldb_dn *base,
 
        ret = ltdb_search_async(module, base, scope, tree, attrs,
                                res, &ltdb_search_sync_callback,
-                               0, &handle);
+                               &handle);
 
-       if (ret != LDB_SUCCESS)
-               return ret;
+       if (ret == LDB_SUCCESS) {
+               ret = ldb_async_wait(module->ldb, handle, LDB_WAIT_ALL);
+               talloc_free(handle);
+       }
 
-       ret = ldb_async_wait(module->ldb, handle, LDB_WAIT_ALL);
+       if (ret != LDB_SUCCESS) {
+               talloc_free(*res);
+       }
 
-       talloc_free(handle);
        return ret;
 }
 
index da9596199aaa37334ba78ade20c595d87be411a0..082534865868dae0fd1e70ba62c1602931cb89a0 100644 (file)
@@ -80,8 +80,7 @@ static int ltdb_err_map(enum TDB_ERROR tdb_code)
 
 struct ldb_async_handle *init_ltdb_handle(struct ltdb_private *ltdb, struct ldb_module *module,
                                          void *context,
-                                         int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
-                                         int timeout)
+                                         int (*callback)(struct ldb_context *, void *, struct ldb_async_result *))
 {
        struct ltdb_async_context *ac;
        struct ldb_async_handle *h;
@@ -104,7 +103,6 @@ struct ldb_async_handle *init_ltdb_handle(struct ltdb_private *ltdb, struct ldb_
        ac->module = module;
        ac->context = context;
        ac->callback = callback;
-       ac->timeout = timeout;
 
        return h;
 }
@@ -259,14 +257,13 @@ done:
 static int ltdb_add_async(struct ldb_module *module, const struct ldb_message *msg,
                          void *context,
                          int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
-                         int timeout,
                          struct ldb_async_handle **handle)
 {
        struct ltdb_private *ltdb = talloc_get_type(module->private_data, struct ltdb_private);
        struct ltdb_async_context *ltdb_ac;
        int ret = LDB_ERR_OPERATIONS_ERROR;
 
-       *handle = init_ltdb_handle(ltdb, module, context, callback, timeout);
+       *handle = init_ltdb_handle(ltdb, module, context, callback);
        if (*handle == NULL) {
                return ret;
        }
@@ -305,7 +302,7 @@ static int ltdb_add(struct ldb_module *module, const struct ldb_message *msg)
        struct ldb_async_handle *handle;
        int ret;
 
-       ret = ltdb_add_async(module, msg, NULL, NULL, 0, &handle);
+       ret = ltdb_add_async(module, msg, NULL, NULL, &handle);
 
        if (ret != LDB_SUCCESS)
                return ret;
@@ -347,7 +344,6 @@ int ltdb_delete_noindex(struct ldb_module *module, const struct ldb_dn *dn)
 static int ltdb_delete_async(struct ldb_module *module, const struct ldb_dn *dn,
                             void *context,
                             int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
-                            int timeout,
                             struct ldb_async_handle **handle)
 {
        struct ltdb_private *ltdb = talloc_get_type(module->private_data, struct ltdb_private);
@@ -361,7 +357,7 @@ static int ltdb_delete_async(struct ldb_module *module, const struct ldb_dn *dn,
                goto failed;
        }
 
-       *handle = init_ltdb_handle(ltdb, module, context, callback, timeout);
+       *handle = init_ltdb_handle(ltdb, module, context, callback);
        if (*handle == NULL) {
                goto failed;
        }
@@ -410,8 +406,7 @@ static int ltdb_delete(struct ldb_module *module, const struct ldb_dn *dn)
        struct ldb_async_handle *handle;
        int ret;
 
-       ret = ltdb_delete_async(module, dn,
-                               NULL, NULL, 0, &handle);
+       ret = ltdb_delete_async(module, dn, NULL, NULL, &handle);
 
        if (ret != LDB_SUCCESS)
                return ret;
@@ -737,7 +732,6 @@ failed:
 static int ltdb_modify_async(struct ldb_module *module, const struct ldb_message *msg,
                          void *context,
                          int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
-                         int timeout,
                          struct ldb_async_handle **handle)
 {
        struct ltdb_private *ltdb = talloc_get_type(module->private_data, struct ltdb_private);
@@ -746,7 +740,7 @@ static int ltdb_modify_async(struct ldb_module *module, const struct ldb_message
 
        *handle = NULL;
 
-       *handle = init_ltdb_handle(ltdb, module, context, callback, timeout);
+       *handle = init_ltdb_handle(ltdb, module, context, callback);
        if (*handle == NULL) {
                return ret;
        }
@@ -785,7 +779,7 @@ static int ltdb_modify(struct ldb_module *module, const struct ldb_message *msg)
        struct ldb_async_handle *handle;
        int ret;
 
-       ret = ltdb_modify_async(module, msg, NULL, NULL, 0, &handle);
+       ret = ltdb_modify_async(module, msg, NULL, NULL, &handle);
 
        if (ret != LDB_SUCCESS)
                return ret;
@@ -802,7 +796,6 @@ static int ltdb_modify(struct ldb_module *module, const struct ldb_message *msg)
 static int ltdb_rename_async(struct ldb_module *module, const struct ldb_dn *olddn, const struct ldb_dn *newdn,
                             void *context,
                             int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
-                            int timeout,
                             struct ldb_async_handle **handle)
 {
        struct ltdb_private *ltdb = talloc_get_type(module->private_data, struct ltdb_private);
@@ -816,7 +809,7 @@ static int ltdb_rename_async(struct ldb_module *module, const struct ldb_dn *old
                return ret;
        }
 
-       *handle = init_ltdb_handle(ltdb, module, context, callback, timeout);
+       *handle = init_ltdb_handle(ltdb, module, context, callback);
        if (*handle == NULL) {
                goto failed;
        }
@@ -872,8 +865,7 @@ static int ltdb_rename(struct ldb_module *module, const struct ldb_dn *olddn, co
        struct ldb_async_handle *handle;
        int ret;
 
-       ret = ltdb_rename_async(module, olddn, newdn,
-                               NULL, NULL, 0, &handle);
+       ret = ltdb_rename_async(module, olddn, newdn, NULL, NULL, &handle);
 
        if (ret != LDB_SUCCESS)
                return ret;
@@ -966,7 +958,6 @@ static int ltdb_request(struct ldb_module *module, struct ldb_request *req)
                                        req->op.search.attrs,
                                        req->async.context,
                                        req->async.callback,
-                                       req->async.timeout,
                                        &req->async.handle);
 
        case LDB_ASYNC_ADD:
@@ -974,7 +965,6 @@ static int ltdb_request(struct ldb_module *module, struct ldb_request *req)
                                        req->op.add.message,
                                        req->async.context,
                                        req->async.callback,
-                                       req->async.timeout,
                                        &req->async.handle);
 
        case LDB_ASYNC_MODIFY:
@@ -982,7 +972,6 @@ static int ltdb_request(struct ldb_module *module, struct ldb_request *req)
                                        req->op.mod.message,
                                        req->async.context,
                                        req->async.callback,
-                                       req->async.timeout,
                                        &req->async.handle);
 
        case LDB_ASYNC_DELETE:
@@ -990,7 +979,6 @@ static int ltdb_request(struct ldb_module *module, struct ldb_request *req)
                                        req->op.del.dn,
                                        req->async.context,
                                        req->async.callback,
-                                       req->async.timeout,
                                        &req->async.handle);
 
        case LDB_ASYNC_RENAME:
@@ -999,7 +987,6 @@ static int ltdb_request(struct ldb_module *module, struct ldb_request *req)
                                        req->op.rename.newdn,
                                        req->async.context,
                                        req->async.callback,
-                                       req->async.timeout,
                                        &req->async.handle);
 
        default:
index 5c76463ff78c7ac3ff6c9751909b4fd603a206f9..196103ad6b8fe4400cf252d8ac5ab685a6533575 100644 (file)
@@ -44,7 +44,6 @@ struct ltdb_async_context {
 
        /* async stuff */
        void *context;
-       int timeout;
        int (*callback)(struct ldb_context *, void *, struct ldb_async_result *);
 };
 
@@ -106,7 +105,6 @@ int ltdb_search_async(struct ldb_module *module, const struct ldb_dn *base,
                      const char * const *attrs,
                      void *context,
                      int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
-                     int timeout,
                      struct ldb_async_handle **handle);
 int ltdb_search_bytree(struct ldb_module *module, const struct ldb_dn *base,
                       enum ldb_scope scope, struct ldb_parse_tree *tree,
@@ -116,8 +114,7 @@ int ltdb_search_bytree(struct ldb_module *module, const struct ldb_dn *base,
 /* The following definitions come from lib/ldb/ldb_tdb/ldb_tdb.c  */
 struct ldb_async_handle *init_ltdb_handle(struct ltdb_private *ltdb, struct ldb_module *module,
                                          void *context,
-                                         int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
-                                         int timeout);
+                                         int (*callback)(struct ldb_context *, void *, struct ldb_async_result *));
 struct TDB_DATA ltdb_key(struct ldb_module *module, const struct ldb_dn *dn);
 int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flgs);
 int ltdb_delete_noindex(struct ldb_module *module, const struct ldb_dn *dn);