s4/ldap: Refactor the fix for ldap nested searches
authorKamen Mazdrashki <kamen.mazdrashki@postpath.com>
Fri, 29 Jan 2010 17:05:51 +0000 (19:05 +0200)
committerAnatoliy Atanasov <anatoliy.atanasov@postpath.com>
Wed, 17 Feb 2010 16:03:31 +0000 (18:03 +0200)
Current implementation synchronizes processing for
all types of LDAP request, not only LDAP_Search ones.

Synchronization for ldap replies processing is done
locally in ldb_ildap module as this concerns only
ildb_callback() function.

Signed-off-by: Anatoliy Atanasov <anatoliy.atanasov@postpath.com>
source4/lib/ldb/ldb_ildap/ldb_ildap.c
source4/libcli/ldap/ldap_client.h

index 6eb2e1719c8b2b50abe52506037b9263e01c1e74..b731f6570bba163b2692df1d108003f011bce4e4 100644 (file)
@@ -61,6 +61,10 @@ struct ildb_context {
        struct ildb_private *ildb;
        struct ldap_request *ireq;
 
+       /* indicate we are already processing
+        * the ldap_request in ildb_callback() */
+       bool in_ildb_callback;
+
        bool done;
 
        struct ildb_destructor_ctx *dc;
@@ -223,6 +227,13 @@ static void ildb_callback(struct ldap_request *req)
        request_done = false;
        controls = NULL;
 
+       /* check if we are already processing this request */
+       if (ac->in_ildb_callback) {
+               return;
+       }
+       /* mark the request as being in process */
+       ac->in_ildb_callback = true;
+
        if (!NT_STATUS_IS_OK(req->status)) {
                ret = ildb_map_error(ac->module, req->status);
                ildb_request_done(ac, NULL, ret);
@@ -278,13 +289,6 @@ static void ildb_callback(struct ldap_request *req)
                break;
 
        case LDAP_TAG_SearchRequest:
-               /* check if we are already processing this request */
-               if (req->in_dispatch_replies) {
-                       return;
-               }
-
-               req->in_dispatch_replies = true;
-
                /* loop over all messages */
                for (i = 0; i < req->num_replies; i++) {
 
@@ -359,8 +363,6 @@ static void ildb_callback(struct ldap_request *req)
                        }
                }
 
-               req->in_dispatch_replies = false;
-
                talloc_free(req->replies);
                req->replies = NULL;
                req->num_replies = 0;
@@ -384,6 +386,10 @@ static void ildb_callback(struct ldap_request *req)
        if (request_done) {
                ildb_request_done(ac, controls, ret);
        }
+
+       /* unmark the request as beign in progress */
+       ac->in_ildb_callback = false;
+
        return;
 }
 
index d6ca29f8a7dac13ef2ca5cd427fd3c5e6825b732..084de2e6dc3cac59d7b27321494957ff42aa464b 100644 (file)
@@ -37,10 +37,6 @@ struct ldap_request {
        int num_replies;
        struct ldap_message **replies;
 
-       /* mark while we are processing replies
-        * in request of type LDAP_TAG_SearchRequest */
-       bool in_dispatch_replies;
-
        NTSTATUS status;
        DATA_BLOB data;
        struct {