]> git.sur5r.net Git - openldap/commitdiff
Update to the 'gentle SIGHUP' patch. (ITS#1679)
authorKurt Zeilenga <kurt@openldap.org>
Wed, 12 Jun 2002 15:43:19 +0000 (15:43 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Wed, 12 Jun 2002 15:43:19 +0000 (15:43 +0000)
- Let write operations return unwilling-to-perform after
  'gentle shutdown' has been initiated.
- Change -1 to 2 in slapd_gentle_shutdown and slapd_shutdown, since
  sig_atomic_t can be unsigned (ITS#1736).  The 'gentle SIGHUP' patch
  is older than ITS#1736 but was applied later, so it reintroduced
  the problem.

Hallvard B. Furuseth <h.b.furuseth@usit.uio.no>, June 2002.

doc/man/man5/slapd.conf.5
servers/slapd/daemon.c

index 6bae0f6bc93b78c9dcd60c6d58a8a86366ee514c..185ef1a1de8dea296a3130aec48d454c39ff1eae 100644 (file)
@@ -208,7 +208,8 @@ disables StartTLS if authenticated (see also
 A SIGHUP signal will only cause a 'gentle' shutdown-attempt:
 .B Slapd
 will stop listening for new connections, but will not close the
-connections to the current clients.  It terminates when all clients
+connections to the current clients.  Future write operations return
+unwilling-to-perform, though.  Slapd terminates when all clients
 have closed their connections (if they ever do), or \- as before \-
 if it receives a SIGTERM signal.  This can be useful if you wish to
 terminate the server and start a new
index 137734c104b8d3a3d2fb8557cd4d137c911d21e1..80de649bea208adccf645b2ac580e0e00bb2ee10 100644 (file)
@@ -237,7 +237,7 @@ void slapd_remove(ber_socket_t s, int wake) {
        FD_CLR( s, &slap_daemon.sd_writers );
 
        ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
-       WAKE_LISTENER(wake || slapd_gentle_shutdown < 0);
+       WAKE_LISTENER(wake || slapd_gentle_shutdown == 2);
 }
 
 void slapd_clr_write(ber_socket_t s, int wake) {
@@ -1114,17 +1114,18 @@ slapd_daemon_task(
                if( slapd_gentle_shutdown ) {
                        ber_socket_t active;
 
-                       if( slapd_gentle_shutdown > 0 ) {
+                       if( slapd_gentle_shutdown == 1 ) {
                                Debug( LDAP_DEBUG_ANY, "slapd gentle shutdown\n", 0, 0, 0 );
                                close_listeners( 1 );
-                               slapd_gentle_shutdown = -1;
+                               global_restrictops |= SLAP_RESTRICT_OP_WRITES;
+                               slapd_gentle_shutdown = 2;
                        }
 
                        ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
                        active = slap_daemon.sd_nactives;
                        ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
                        if( active == 0 ) {
-                               slapd_shutdown = -1;
+                               slapd_shutdown = 2;
                                break;
                        }
                }
@@ -1780,7 +1781,7 @@ slapd_daemon_task(
 #endif
        }
 
-       if( slapd_gentle_shutdown >= 0 )
+       if( slapd_gentle_shutdown != 2 )
                close_listeners ( 0 );
        free ( slap_listeners );
        slap_listeners = NULL;