]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
tldap: Make sure all requests are cancelled on rundown
authorVolker Lendecke <vl@samba.org>
Tue, 11 Aug 2020 15:44:42 +0000 (17:44 +0200)
committerKarolin Seeger <kseeger@samba.org>
Mon, 31 Aug 2020 08:12:23 +0000 (08:12 +0000)
Put messages into the ld->pending array before sending them out, not
after they have been sent.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=14465

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit 2a2a6b27cccb2409d321c7e03feb8baa047d1bf4)

source3/lib/tldap.c

index de9f0c70ff117179251137b2c46c348b25605458..52012ab9a55eddc440c114816e9dbdda0c632b31 100644 (file)
@@ -29,6 +29,7 @@
 #include "../lib/util/tevent_unix.h"
 
 static TLDAPRC tldap_simple_recv(struct tevent_req *req);
+static bool tldap_msg_set_pending(struct tevent_req *req);
 
 #define TEVENT_TLDAP_RC_MAGIC (0x87bcd26e)
 
@@ -521,6 +522,11 @@ static struct tevent_req *tldap_msg_send(TALLOC_CTX *mem_ctx,
                return tevent_req_post(req, ev);
        }
 
+       if (!tldap_msg_set_pending(req)) {
+               tevent_req_oom(req);
+               return tevent_req_post(req, ev);;
+       }
+
        state->iov.iov_base = (void *)blob.data;
        state->iov.iov_len = blob.length;
 
@@ -633,12 +639,6 @@ static void tldap_msg_sent(struct tevent_req *subreq)
        TALLOC_FREE(subreq);
        if (nwritten == -1) {
                tldap_context_disconnect(state->ld, TLDAP_SERVER_DOWN);
-               tevent_req_ldap_error(req, TLDAP_SERVER_DOWN);
-               return;
-       }
-
-       if (!tldap_msg_set_pending(req)) {
-               tevent_req_oom(req);
                return;
        }
 }