From: Volker Lendecke Date: Tue, 11 Aug 2020 15:44:42 +0000 (+0200) Subject: tldap: Make sure all requests are cancelled on rundown X-Git-Tag: samba-4.11.14~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bf7dfed4f9075efb4ff5d9347c496631865b5e8b;p=thirdparty%2Fsamba.git tldap: Make sure all requests are cancelled on rundown 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 Reviewed-by: Stefan Metzmacher (cherry picked from commit 2a2a6b27cccb2409d321c7e03feb8baa047d1bf4) --- diff --git a/source3/lib/tldap.c b/source3/lib/tldap.c index de9f0c70ff1..52012ab9a55 100644 --- a/source3/lib/tldap.c +++ b/source3/lib/tldap.c @@ -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; } }