From 4588f4e528170bb5e57c99daad4acacd47f078de Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ond=C5=99ej=20Kuzn=C3=ADk?= Date: Fri, 13 Aug 2021 16:01:13 +0100 Subject: [PATCH] ITS#9597 Fix NoD support --- servers/lloadd/connection.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/servers/lloadd/connection.c b/servers/lloadd/connection.c index 7685c03b7e..7398734153 100644 --- a/servers/lloadd/connection.c +++ b/servers/lloadd/connection.c @@ -515,7 +515,7 @@ connections_walk( int lload_connection_close( LloadConnection *c, void *arg ) { - int gentle = *(int *)arg; + int unlock, gentle = *(int *)arg; LloadOperation *op; Debug( LDAP_DEBUG_CONNS, "lload_connection_close: " @@ -526,20 +526,28 @@ lload_connection_close( LloadConnection *c, void *arg ) assert( IS_ALIVE( c, c_refcnt ) ); /* Need to acquire this first, even if we won't need it */ + unlock = 1; checked_lock( &c->c_io_mutex ); CONNECTION_LOCK(c); - /* Only if it's a client */ - if ( c->c_state == LLOAD_C_OPEN && c->c_destroy == clients_destroy ) { + /* Only if it's a usable client */ + if ( ( c->c_state == LLOAD_C_READY || c->c_state == LLOAD_C_BINDING ) && + c->c_destroy == client_destroy ) { if ( c->c_pendingber != NULL || (c->c_pendingber = ber_alloc()) != NULL ) { ber_printf( c->c_pendingber, "t{tit{esss}}", LDAP_TAG_MESSAGE, LDAP_TAG_MSGID, LDAP_RES_UNSOLICITED, LDAP_RES_EXTENDED, LDAP_UNAVAILABLE, "", "connection closing", LDAP_NOTICE_OF_DISCONNECTION ); + unlock = 0; + checked_unlock( &c->c_io_mutex ); + CONNECTION_UNLOCK(c); + connection_write_cb( -1, 0, c ); + CONNECTION_LOCK(c); } } - checked_unlock( &c->c_io_mutex ); + if ( unlock ) + checked_unlock( &c->c_io_mutex ); if ( !gentle || !c->c_ops ) { CONNECTION_DESTROY(c); -- 2.47.3