From: Kurt Zeilenga Date: Wed, 18 Nov 1998 17:45:32 +0000 (+0000) Subject: Update LinuxThread signal handling. Hide #ifdef hell in ac/signal.h. X-Git-Tag: OPENLDAP_SLAPD_BACK_LDAP~1094 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3111cfa3bd3e7485b3fa7a922568a435cb61b94e;p=openldap Update LinuxThread signal handling. Hide #ifdef hell in ac/signal.h. --- diff --git a/include/ac/signal.h b/include/ac/signal.h index 56597a0bfe..e5776f387c 100644 --- a/include/ac/signal.h +++ b/include/ac/signal.h @@ -11,4 +11,36 @@ #define SIGNAL signal #endif +#if !defined( LDAP_SIGUSR1 ) || !defined( LDAP_SIGUSR2 ) +#undef LDAP_SIGUSR1 +#undef LDAP_SIGUSR2 + +# ifndef HAVE_LINUX_THREADS +# define LDAP_SIGUSR1 SIGUSR1 +# define LDAP_SIGUSR2 SIGUSR2 + +# else + /* + LinuxThreads implemented unfortunately uses the only + two signals reserved for user applications. This forces + OpenLDAP to use, hopefullly unused, signals reserved + for other uses. + */ + +# if defined( SIGSTKFLT ) +# define LDAP_SIGUSR1 SIGSTKFLT +# elif defined ( SIGSYS ) +# define LDAP_SIGUSR1 SIGSYS +# endif + +# ifdef defined( SIGUNUSED ) +# define LDAP_SIGUSR2 SIGUNUSED +# elif defined ( SIGINFO ) +# define LDAP_SIGUSR1 SIGINFO +# elif defined ( SIGEMT ) +# define LDAP_SIGUSR1 SIGEMT +# endif +# endif +#endif + #endif /* _AC_SIGNAL_H */ diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index 48eb7f13d3..2258f1c2d6 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -127,17 +127,8 @@ slapd_daemon( } (void) SIGNAL( SIGPIPE, SIG_IGN ); -#ifdef HAVE_LINUX_THREADS - /* - * LinuxThreads are implemented using SIGUSR1/USR2, - * so we'll use SIGSTKFLT and SIGUNUSED - */ - (void) SIGNAL( SIGSTKFLT, do_nothing ); - (void) SIGNAL( SIGUNUSED, set_shutdown ); -#else /* !linux */ - (void) SIGNAL( SIGUSR1, do_nothing ); - (void) SIGNAL( SIGUSR2, set_shutdown ); -#endif /* !linux */ + (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 ); @@ -401,17 +392,8 @@ set_shutdown( int sig ) { Debug( LDAP_DEBUG_ANY, "slapd got shutdown signal %d\n", sig, 0, 0 ); slapd_shutdown = 1; -#ifdef HAVE_LINUX_THREADS - /* - * LinuxThreads are implemented using SIGUSR1/USR2, - * so we'll use SIGSTKFLT and SIGUNUSED - */ - pthread_kill( listener_tid, SIGSTKFLT ); - (void) SIGNAL( SIGUNUSED, set_shutdown ); -#else /* !linux */ - pthread_kill( listener_tid, SIGUSR1 ); - (void) SIGNAL( SIGUSR2, set_shutdown ); -#endif /* !linux */ + pthread_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 ); @@ -421,13 +403,5 @@ static void do_nothing( int sig ) { Debug( LDAP_DEBUG_TRACE, "slapd got do_nothing signal %d\n", sig, 0, 0 ); -#ifdef HAVE_LINUX_THREADS - /* - * LinuxThreads are implemented using SIGUSR1/USR2, - * so we'll use SIGSTKFLT and SIGUNUSED - */ - (void) SIGNAL( SIGSTKFLT, do_nothing ); -#else /* !linux */ - (void) SIGNAL( SIGUSR1, do_nothing ); -#endif /* !linux */ + (void) SIGNAL( LDAP_SIGUSR1, do_nothing ); } diff --git a/servers/slapd/result.c b/servers/slapd/result.c index a710e1910f..a18ba20a86 100644 --- a/servers/slapd/result.c +++ b/servers/slapd/result.c @@ -113,11 +113,7 @@ send_ldap_result2( active_threads--; conn->c_writewaiter = 1; -#ifdef HAVE_LINUX_THREADS - pthread_kill( listener_tid, SIGSTKFLT ); -#else /* !linux */ - pthread_kill( listener_tid, SIGUSR1 ); -#endif /* !linux */ + pthread_kill( listener_tid, LDAP_SIGUSR1 ); pthread_cond_wait( &conn->c_wcv, &active_threads_mutex ); pthread_mutex_unlock( &active_threads_mutex ); @@ -348,7 +344,7 @@ send_search_entry( pthread_mutex_lock( &active_threads_mutex ); active_threads--; conn->c_writewaiter = 1; - pthread_kill( listener_tid, SIGUSR1 ); + pthread_kill( listener_tid, LDAP_SIGUSR1 ); pthread_cond_wait( &conn->c_wcv, &active_threads_mutex ); pthread_mutex_unlock( &active_threads_mutex ); diff --git a/servers/slurpd/admin.c b/servers/slurpd/admin.c index b5aecdca0f..4c814b2b00 100644 --- a/servers/slurpd/admin.c +++ b/servers/slurpd/admin.c @@ -39,5 +39,5 @@ RETSIGTYPE do_admin( int sig ) { sglob->rq->rq_dump( sglob->rq ); - (void) SIGNAL( SIGUSR2, do_admin ); + (void) SIGNAL( LDAP_SIGUSR2, do_admin ); } diff --git a/servers/slurpd/fm.c b/servers/slurpd/fm.c index be02d2b6f9..fb51270ecd 100644 --- a/servers/slurpd/fm.c +++ b/servers/slurpd/fm.c @@ -55,13 +55,8 @@ fm( * SIG(UNUSED|USR2) - causes slurpd to read its administrative interface file. * (not yet implemented). */ -#ifdef HAVE_LINUX_THREADS - (void) SIGNAL( SIGSTKFLT, do_nothing ); - (void) SIGNAL( SIGUNUSED, do_admin ); -#else - (void) SIGNAL( SIGUSR1, do_nothing ); - (void) SIGNAL( SIGUSR2, do_admin ); -#endif + (void) SIGNAL( LDAP_SIGUSR1, do_nothing ); + (void) SIGNAL( LDAP_SIGUSR2, do_admin ); (void) SIGNAL( SIGTERM, set_shutdown ); (void) SIGNAL( SIGINT, set_shutdown ); (void) SIGNAL( SIGHUP, set_shutdown ); @@ -140,11 +135,7 @@ set_shutdown(int x) int i; sglob->slurpd_shutdown = 1; /* set flag */ -#ifdef HAVE_LINUX_THREADS - pthread_kill( sglob->fm_tid, SIGSTKFLT ); /* wake up file mgr */ -#else - pthread_kill( sglob->fm_tid, SIGUSR1 ); /* wake up file mgr */ -#endif + pthread_kill( sglob->fm_tid, LDAP_SIGUSR1 ); /* wake up file mgr */ sglob->rq->rq_lock( sglob->rq ); /* lock queue */ pthread_cond_broadcast( &(sglob->rq->rq_more) ); /* wake repl threads */ for ( i = 0; i < sglob->num_replicas; i++ ) { @@ -165,11 +156,7 @@ set_shutdown(int x) RETSIGTYPE do_nothing(int i) { -#ifdef HAVE_LINUX_THREADS - (void) SIGNAL( SIGSTKFLT, do_nothing ); -#else - (void) SIGNAL( SIGUSR1, do_nothing ); -#endif + (void) SIGNAL( LDAP_SIGUSR1, do_nothing ); } diff --git a/servers/slurpd/ri.c b/servers/slurpd/ri.c index 5f27e121ac..d2aa7de252 100644 --- a/servers/slurpd/ri.c +++ b/servers/slurpd/ri.c @@ -45,11 +45,7 @@ Ri_process( int rc ; char *errmsg; -#ifdef HAVE_LINUX_THREADS - (void) SIGNAL( SIGSTKFLT, do_nothing ); -#else - (void) SIGNAL( SIGUSR1, do_nothing ); -#endif + (void) SIGNAL( LDAP_SIGUSR1, do_nothing ); (void) SIGNAL( SIGPIPE, SIG_IGN ); if ( ri == NULL ) { Debug( LDAP_DEBUG_ANY, "Error: Ri_process: ri == NULL!\n", 0, 0, 0 ); @@ -149,13 +145,8 @@ Ri_wake( if ( ri == NULL ) { return; } -#ifdef HAVE_LINUX_THREADS - pthread_kill( ri->ri_tid, SIGSTKFLT ); - (void) SIGNAL( SIGSTKFLT, do_nothing ); -#else - pthread_kill( ri->ri_tid, SIGUSR1 ); - (void) SIGNAL( SIGUSR1, do_nothing ); -#endif + pthread_kill( ri->ri_tid, LDAP_SIGUSR1 ); + (void) SIGNAL( LDAP_SIGUSR1, do_nothing ); }