From: Nick Porter Date: Tue, 10 Sep 2024 09:05:43 +0000 (+0100) Subject: Correct conditions for reparenting query when cancelling trunk request X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=da3d0db6aabc3eeaaa924125650ba497e1287a28;p=thirdparty%2Ffreeradius-server.git Correct conditions for reparenting query when cancelling trunk request --- diff --git a/src/lib/ldap/base.c b/src/lib/ldap/base.c index 20294891838..39cd3e5bfe3 100644 --- a/src/lib/ldap/base.c +++ b/src/lib/ldap/base.c @@ -650,10 +650,24 @@ static void ldap_trunk_query_cancel(UNUSED request_t *request, UNUSED fr_signal_ if (!query->treq) return; /* - * The query needs to be parented by the treq so that it still - * exists when the cancel_mux callback is run. + * Depending on the state of the trunk request, the query needs to + * be parented by the treq so that it still exists when the + * cancel_mux callback is run. + * Other states free the trunk request (and its children) immediately. + * So no re-parenting is needed. */ - talloc_steal(query->treq, query); + switch (query->treq->state) { + case TRUNK_REQUEST_STATE_PARTIAL: + case TRUNK_REQUEST_STATE_SENT: + case TRUNK_REQUEST_STATE_CANCEL: + case TRUNK_REQUEST_STATE_CANCEL_PARTIAL: + case TRUNK_REQUEST_STATE_CANCEL_SENT: + case TRUNK_REQUEST_STATE_CANCEL_COMPLETE: + talloc_steal(query->treq, query); + break; + default: + break; + } trunk_request_signal_cancel(query->treq);