]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
Work around libevent base not waking up on shutdown
authorOndřej Kuzník <okuznik@symas.com>
Mon, 26 Mar 2018 12:28:38 +0000 (13:28 +0100)
committerOndřej Kuzník <okuznik@symas.com>
Tue, 17 Nov 2020 17:58:15 +0000 (17:58 +0000)
servers/lloadd/daemon.c

index e2b2ef2d38b9399321c3fa64a777d49985c70ffc..3ae3dfca253c82d257f68bb5c6bf9346c7cf85d3 100644 (file)
@@ -1363,8 +1363,19 @@ lloadd_daemon( struct event_base *daemon_base )
     /* wait for the listener threads to complete */
     destroy_listeners();
 
+    /* TODO: Mark upstream connections closing */
+
+    for ( i = 0; i < lload_daemon_threads; i++ ) {
+        /*
+         * https://github.com/libevent/libevent/issues/623
+         * deleting the event doesn't notify the base, just activate it and
+         * let it delete itself
+         */
+        event_active( lload_daemon[i].wakeup_event, EV_READ, 0 );
+    }
+
     for ( i = 0; i < lload_daemon_threads; i++ ) {
-        event_del( lload_daemon[i].wakeup_event );
+        ldap_pvt_thread_join( daemon_tid[i], (void *)NULL );
     }
 
 #ifndef BALANCER_MODULE
@@ -1382,10 +1393,6 @@ lloadd_daemon( struct event_base *daemon_base )
     lload_bindconf_free( &bindconf );
     evdns_base_free( dnsbase, 0 );
 
-    for ( i = 0; i < lload_daemon_threads; i++ ) {
-        ldap_pvt_thread_join( daemon_tid[i], (void *)NULL );
-    }
-
     ch_free( daemon_tid );
     daemon_tid = NULL;
 
@@ -1406,9 +1413,7 @@ daemon_wakeup_cb( evutil_socket_t sig, short what, void *arg )
     Debug( LDAP_DEBUG_TRACE, "daemon_wakeup_cb: "
             "Daemon thread %d woken up\n",
             tid );
-    if ( slapd_shutdown ) {
-        event_base_loopexit( lload_daemon[tid].base, NULL );
-    }
+    event_del( lload_daemon[tid].wakeup_event );
 }
 
 LloadChange lload_change = { .type = LLOAD_UNDEFINED };