From: Kurt Zeilenga Date: Wed, 12 Jun 2002 15:43:19 +0000 (+0000) Subject: Update to the 'gentle SIGHUP' patch. (ITS#1679) X-Git-Tag: NO_SLAP_OP_BLOCKS~1474 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=faf91f1f1f3c38b17fd04c7bb86e29889bd32a7b;p=openldap Update to the 'gentle SIGHUP' patch. (ITS#1679) - 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 , June 2002. --- diff --git a/doc/man/man5/slapd.conf.5 b/doc/man/man5/slapd.conf.5 index 6bae0f6bc9..185ef1a1de 100644 --- a/doc/man/man5/slapd.conf.5 +++ b/doc/man/man5/slapd.conf.5 @@ -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 diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index 137734c104..80de649bea 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -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;