From ec2e980376e643c15311ea5798a9609a550d0aba Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Thu, 19 Nov 1998 01:33:57 +0000 Subject: [PATCH] Apply LinuxThread changes to support alpha/sparc signals --- include/ac/signal.h | 46 ++++++++++++++++++++++++++++++++++++++++++ servers/slapd/daemon.c | 36 +++++---------------------------- servers/slapd/result.c | 8 ++------ servers/slurpd/admin.c | 2 +- servers/slurpd/fm.c | 25 ++++++----------------- servers/slurpd/ri.c | 17 ++++------------ 6 files changed, 64 insertions(+), 70 deletions(-) create mode 100644 include/ac/signal.h diff --git a/include/ac/signal.h b/include/ac/signal.h new file mode 100644 index 0000000000..e5776f387c --- /dev/null +++ b/include/ac/signal.h @@ -0,0 +1,46 @@ +/* Generic signal.h */ + +#ifndef _AC_SIGNAL_H +#define _AC_SIGNAL_H + +#include + +#ifdef HAVE_SIGSET +#define SIGNAL sigset +#else +#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..5063927180 100644 --- a/servers/slurpd/fm.c +++ b/servers/slurpd/fm.c @@ -51,17 +51,12 @@ fm( /* Set up our signal handlers: * SIG{TERM,INT,HUP} causes a shutdown - * SIG(STKFLT|USR1) - does nothing, used to wake up sleeping threads. - * SIG(UNUSED|USR2) - causes slurpd to read its administrative interface file. + * LDAP_SIGUSR1 - does nothing, used to wake up sleeping threads. + * LDAP_SIGUSR2 - 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 d96482d13c..de335061ab 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 ); @@ -137,7 +133,7 @@ Ri_process( /* * Wake a replication thread which may be sleeping. - * Send it a SIG(STKFLT|USR1). + * Send it a LDAP_SIGUSR1. */ static void Ri_wake( @@ -147,13 +143,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 ); } -- 2.47.2