From: Arran Cudbard-Bell Date: Thu, 14 Oct 2021 17:43:26 +0000 (-0500) Subject: ldap: The on close watcher should be oneshot X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=846c71c73ded7e0d4c4bb279b6be1d724cee754e;p=thirdparty%2Ffreeradius-server.git ldap: The on close watcher should be oneshot otherwise we accrue onclose watchers pointint to fr_ldap_connection_t that have been freed --- diff --git a/src/lib/ldap/connection.c b/src/lib/ldap/connection.c index fe98b7eb86f..3ffb7c7e816 100644 --- a/src/lib/ldap/connection.c +++ b/src/lib/ldap/connection.c @@ -87,7 +87,7 @@ int fr_ldap_connection_configure(fr_ldap_connection_t *c, fr_ldap_config_t const } #endif - DEBUG3("New libldap handle %p", handle); + DEBUG3("New connection %p libldap handle %p", c, handle); c->config = config; c->handle = handle; @@ -259,10 +259,10 @@ static int _ldap_connection_free(fr_ldap_connection_t *c) NUM_ELEMENTS(our_clientctrls), c, NULL, NULL); - DEBUG3("Closing libldap handle %p", c->handle); + DEBUG3("Closing connection %p libldap handle %p", c->handle, c); ldap_unbind_ext(c->handle, our_serverctrls, our_clientctrls); /* Same code as ldap_unbind_ext_s */ #else - DEBUG3("Closing libldap handle %p", c->handle); + DEBUG3("Closing connection %p libldap handle %p", c->handle, c); ldap_unbind(c->handle); /* Same code as ldap_unbind_s */ #endif c->handle = NULL; @@ -365,7 +365,7 @@ static fr_connection_state_t _ldap_connection_init(void **h, fr_connection_t *co c = fr_ldap_connection_alloc(conn); c->conn = conn; - fr_connection_add_watch_pre(conn, FR_CONNECTION_STATE_CLOSED, _ldap_connection_close_watch, false, c); + fr_connection_add_watch_pre(conn, FR_CONNECTION_STATE_CLOSED, _ldap_connection_close_watch, true, c); /* * Configure/allocate the libldap handle