From: Ondřej Kuzník Date: Tue, 21 Apr 2020 14:02:47 +0000 (+0100) Subject: ITS#9597 Send Notice of Disconnection when shutting down a client connection X-Git-Tag: OPENLDAP_REL_ENG_2_6_0~101 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b66a62799d223398a0dc44584c12b2e32a7b7840;p=thirdparty%2Fopenldap.git ITS#9597 Send Notice of Disconnection when shutting down a client connection --- diff --git a/servers/lloadd/connection.c b/servers/lloadd/connection.c index 5644138882..7685c03b7e 100644 --- a/servers/lloadd/connection.c +++ b/servers/lloadd/connection.c @@ -525,7 +525,22 @@ lload_connection_close( LloadConnection *c, void *arg ) /* We were approached from the connection list */ assert( IS_ALIVE( c, c_refcnt ) ); + /* Need to acquire this first, even if we won't need it */ + 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 ) { + 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 ); + } + } + checked_unlock( &c->c_io_mutex ); + if ( !gentle || !c->c_ops ) { CONNECTION_DESTROY(c); return LDAP_SUCCESS;