]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#9597 Send Notice of Disconnection when shutting down a client connection
authorOndřej Kuzník <okuznik@symas.com>
Tue, 21 Apr 2020 14:02:47 +0000 (15:02 +0100)
committerOndřej Kuzník <okuznik@symas.com>
Fri, 13 Aug 2021 09:57:13 +0000 (10:57 +0100)
servers/lloadd/connection.c

index 5644138882ce5e912c3a2d8aeb34246fd2aa813f..7685c03b7edcea5fed7ee09fe968f86b41371363 100644 (file)
@@ -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;