Connection *c;
static volatile sig_atomic_t slapd_shutdown = 0;
-static void set_shutdown(int sig);
-static void do_nothing (int sig);
-
-int listener_running = 1;
-
/* a link to the slapd.conf configuration parameters */
extern char *slapd_pid_file;
exit( 1 );
}
- (void) SIGNAL( SIGPIPE, SIG_IGN );
- (void) SIGNAL( LDAP_SIGUSR1, do_nothing );
- (void) SIGNAL( LDAP_SIGUSR2, set_shutdown );
- (void) SIGNAL( SIGTERM, set_shutdown );
- (void) SIGNAL( SIGINT, set_shutdown );
- (void) SIGNAL( SIGHUP, set_shutdown );
-
Debug( LDAP_DEBUG_ANY, "slapd starting\n", 0, 0, 0 );
if (( slapd_pid_file != NULL ) &&
}
ldap_pvt_thread_mutex_unlock( &active_threads_mutex );
- /* a braindead signal handling in LINUX Kernel Threads needs some
- provision, so that the top thread is not killed before the
- listener thread (should be better implemented by cond_vars) */
- listener_running = 0;
-
return NULL;
}
-static void
-set_shutdown( int sig )
+void
+slap_set_shutdown( int sig )
{
Debug( LDAP_DEBUG_ANY, "slapd got shutdown signal %d\n", sig, 0, 0 );
slapd_shutdown = 1;
ldap_pvt_thread_kill( listener_tid, LDAP_SIGUSR1 );
- (void) SIGNAL( LDAP_SIGUSR2, set_shutdown );
- (void) SIGNAL( SIGTERM, set_shutdown );
- (void) SIGNAL( SIGINT, set_shutdown );
- (void) SIGNAL( SIGHUP, set_shutdown );
+
+ /* reinstall self */
+ (void) SIGNAL( sig, slap_set_shutdown );
}
-static void
-do_nothing( int sig )
+void
+slap_do_nothing( int sig )
{
Debug( LDAP_DEBUG_TRACE, "slapd got do_nothing signal %d\n", sig, 0, 0 );
- (void) SIGNAL( LDAP_SIGUSR1, do_nothing );
+
+ /* reinstall self */
+ (void) SIGNAL( sig, slap_do_nothing );
}
#include <stdio.h>
+#include <ac/signal.h>
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/time.h>
#include "slap.h"
#include "lutil.h" /* Get lutil_detach() */
-
-extern int listener_running;
-
/*
* when more than one slapd is running on one machine, each one might have
* it's own LOCAL for syslogging and must have its own pid/args files
if ( ! inetd ) {
int status;
+ (void) SIGNAL( SIGPIPE, SIG_IGN );
+ (void) SIGNAL( LDAP_SIGUSR1, slap_do_nothing );
+ (void) SIGNAL( LDAP_SIGUSR2, slap_set_shutdown );
+ (void) SIGNAL( SIGTERM, slap_set_shutdown );
+ (void) SIGNAL( SIGINT, slap_set_shutdown );
+ (void) SIGNAL( SIGHUP, slap_set_shutdown );
+
#ifdef LDAP_DEBUG
lutil_detach( ldap_debug, 0 );
#else
"listener ldap_pvt_thread_create failed (%d)\n", status, 0, 0 );
rc = 1;
- } else {
+ } else {
/* wait for the listener thread to complete */
- while ( listener_running )
- ldap_pvt_thread_join( listener_tid, (void *) NULL );
+ ldap_pvt_thread_join( listener_tid, (void *) NULL );
}
} else {
extern int slap_shutdown LDAP_P((int dbnum));
extern int slap_destroy LDAP_P((void));
-extern void * slapd_daemon LDAP_P((void *port));
+extern void * slapd_daemon LDAP_P((void *port));
+extern void slap_set_shutdown LDAP_P((int sig));
+extern void slap_do_nothing LDAP_P((int sig));
extern void config_info LDAP_P((Connection *conn, Operation *op));
extern void do_abandon LDAP_P((Connection *conn, Operation *op));