From: Arran Cudbard-Bell Date: Thu, 14 Oct 2021 18:47:45 +0000 (-0500) Subject: ldap: Don't leave the ldap handle's fd in the event loop when we're closing the conne... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5776998db7f703188bb85c4a29e691d4e1bb90ef;p=thirdparty%2Ffreeradius-server.git ldap: Don't leave the ldap handle's fd in the event loop when we're closing the connection --- diff --git a/src/lib/ldap/connection.c b/src/lib/ldap/connection.c index bd04ef85ed9..8c1e7c22f59 100644 --- a/src/lib/ldap/connection.c +++ b/src/lib/ldap/connection.c @@ -224,8 +224,21 @@ DIAG_ON(unused-macros) * @param[in] h to close. * @param[in] uctx Connection config and handle. */ -static void _ldap_connection_close(UNUSED fr_event_list_t *el, void *h, UNUSED void *uctx) +static void _ldap_connection_close(fr_event_list_t *el, void *h, UNUSED void *uctx) { + fr_ldap_connection_t *c = talloc_get_type_abort(h, fr_ldap_connection_t); + + /* + * Explicitly remove the file descriptor + * + * Event if the fr_ldap_connection_t has outstanding + * queries, we still don't want its fd in the event loop. + */ + if (c->fd >= 0) { + fr_event_fd_delete(el, c->fd, FR_EVENT_FILTER_IO); + c->fd = -1; + } + talloc_free(h); } @@ -588,6 +601,7 @@ static void ldap_trunk_connection_notify(fr_trunk_connection_t *tconn, fr_connec fr_ldap_connection_t *ldap_conn = talloc_get_type_abort(conn->h, fr_ldap_connection_t); fr_event_fd_cb_t read_fn = NULL; fr_event_fd_cb_t write_fn = NULL; + switch (notify_on) { case FR_TRUNK_CONN_EVENT_NONE: fr_event_fd_delete(el, ldap_conn->fd, FR_EVENT_FILTER_IO);