mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-23 16:19:35 -05:00
Update LinuxThread signal handling. Hide #ifdef hell in ac/signal.h.
This commit is contained in:
parent
499735fec6
commit
3111cfa3bd
6 changed files with 47 additions and 67 deletions
|
|
@ -11,4 +11,36 @@
|
||||||
#define SIGNAL signal
|
#define SIGNAL signal
|
||||||
#endif
|
#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 */
|
#endif /* _AC_SIGNAL_H */
|
||||||
|
|
|
||||||
|
|
@ -127,17 +127,8 @@ slapd_daemon(
|
||||||
}
|
}
|
||||||
|
|
||||||
(void) SIGNAL( SIGPIPE, SIG_IGN );
|
(void) SIGNAL( SIGPIPE, SIG_IGN );
|
||||||
#ifdef HAVE_LINUX_THREADS
|
(void) SIGNAL( LDAP_SIGUSR1, do_nothing );
|
||||||
/*
|
(void) SIGNAL( LDAP_SIGUSR2, set_shutdown );
|
||||||
* 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( SIGTERM, set_shutdown );
|
(void) SIGNAL( SIGTERM, set_shutdown );
|
||||||
(void) SIGNAL( SIGINT, set_shutdown );
|
(void) SIGNAL( SIGINT, set_shutdown );
|
||||||
(void) SIGNAL( SIGHUP, 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 );
|
Debug( LDAP_DEBUG_ANY, "slapd got shutdown signal %d\n", sig, 0, 0 );
|
||||||
slapd_shutdown = 1;
|
slapd_shutdown = 1;
|
||||||
#ifdef HAVE_LINUX_THREADS
|
pthread_kill( listener_tid, LDAP_SIGUSR1 );
|
||||||
/*
|
(void) SIGNAL( LDAP_SIGUSR2, set_shutdown );
|
||||||
* 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 */
|
|
||||||
(void) SIGNAL( SIGTERM, set_shutdown );
|
(void) SIGNAL( SIGTERM, set_shutdown );
|
||||||
(void) SIGNAL( SIGINT, set_shutdown );
|
(void) SIGNAL( SIGINT, set_shutdown );
|
||||||
(void) SIGNAL( SIGHUP, set_shutdown );
|
(void) SIGNAL( SIGHUP, set_shutdown );
|
||||||
|
|
@ -421,13 +403,5 @@ static void
|
||||||
do_nothing( int sig )
|
do_nothing( int sig )
|
||||||
{
|
{
|
||||||
Debug( LDAP_DEBUG_TRACE, "slapd got do_nothing signal %d\n", sig, 0, 0 );
|
Debug( LDAP_DEBUG_TRACE, "slapd got do_nothing signal %d\n", sig, 0, 0 );
|
||||||
#ifdef HAVE_LINUX_THREADS
|
(void) SIGNAL( LDAP_SIGUSR1, do_nothing );
|
||||||
/*
|
|
||||||
* 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 */
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -113,11 +113,7 @@ send_ldap_result2(
|
||||||
active_threads--;
|
active_threads--;
|
||||||
conn->c_writewaiter = 1;
|
conn->c_writewaiter = 1;
|
||||||
|
|
||||||
#ifdef HAVE_LINUX_THREADS
|
pthread_kill( listener_tid, LDAP_SIGUSR1 );
|
||||||
pthread_kill( listener_tid, SIGSTKFLT );
|
|
||||||
#else /* !linux */
|
|
||||||
pthread_kill( listener_tid, SIGUSR1 );
|
|
||||||
#endif /* !linux */
|
|
||||||
|
|
||||||
pthread_cond_wait( &conn->c_wcv, &active_threads_mutex );
|
pthread_cond_wait( &conn->c_wcv, &active_threads_mutex );
|
||||||
pthread_mutex_unlock( &active_threads_mutex );
|
pthread_mutex_unlock( &active_threads_mutex );
|
||||||
|
|
@ -348,7 +344,7 @@ send_search_entry(
|
||||||
pthread_mutex_lock( &active_threads_mutex );
|
pthread_mutex_lock( &active_threads_mutex );
|
||||||
active_threads--;
|
active_threads--;
|
||||||
conn->c_writewaiter = 1;
|
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_cond_wait( &conn->c_wcv, &active_threads_mutex );
|
||||||
pthread_mutex_unlock( &active_threads_mutex );
|
pthread_mutex_unlock( &active_threads_mutex );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,5 +39,5 @@ RETSIGTYPE
|
||||||
do_admin( int sig )
|
do_admin( int sig )
|
||||||
{
|
{
|
||||||
sglob->rq->rq_dump( sglob->rq );
|
sglob->rq->rq_dump( sglob->rq );
|
||||||
(void) SIGNAL( SIGUSR2, do_admin );
|
(void) SIGNAL( LDAP_SIGUSR2, do_admin );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,13 +55,8 @@ fm(
|
||||||
* SIG(UNUSED|USR2) - causes slurpd to read its administrative interface file.
|
* SIG(UNUSED|USR2) - causes slurpd to read its administrative interface file.
|
||||||
* (not yet implemented).
|
* (not yet implemented).
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_LINUX_THREADS
|
(void) SIGNAL( LDAP_SIGUSR1, do_nothing );
|
||||||
(void) SIGNAL( SIGSTKFLT, do_nothing );
|
(void) SIGNAL( LDAP_SIGUSR2, do_admin );
|
||||||
(void) SIGNAL( SIGUNUSED, do_admin );
|
|
||||||
#else
|
|
||||||
(void) SIGNAL( SIGUSR1, do_nothing );
|
|
||||||
(void) SIGNAL( SIGUSR2, do_admin );
|
|
||||||
#endif
|
|
||||||
(void) SIGNAL( SIGTERM, set_shutdown );
|
(void) SIGNAL( SIGTERM, set_shutdown );
|
||||||
(void) SIGNAL( SIGINT, set_shutdown );
|
(void) SIGNAL( SIGINT, set_shutdown );
|
||||||
(void) SIGNAL( SIGHUP, set_shutdown );
|
(void) SIGNAL( SIGHUP, set_shutdown );
|
||||||
|
|
@ -140,11 +135,7 @@ set_shutdown(int x)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
sglob->slurpd_shutdown = 1; /* set flag */
|
sglob->slurpd_shutdown = 1; /* set flag */
|
||||||
#ifdef HAVE_LINUX_THREADS
|
pthread_kill( sglob->fm_tid, LDAP_SIGUSR1 ); /* wake up file mgr */
|
||||||
pthread_kill( sglob->fm_tid, SIGSTKFLT ); /* wake up file mgr */
|
|
||||||
#else
|
|
||||||
pthread_kill( sglob->fm_tid, SIGUSR1 ); /* wake up file mgr */
|
|
||||||
#endif
|
|
||||||
sglob->rq->rq_lock( sglob->rq ); /* lock queue */
|
sglob->rq->rq_lock( sglob->rq ); /* lock queue */
|
||||||
pthread_cond_broadcast( &(sglob->rq->rq_more) ); /* wake repl threads */
|
pthread_cond_broadcast( &(sglob->rq->rq_more) ); /* wake repl threads */
|
||||||
for ( i = 0; i < sglob->num_replicas; i++ ) {
|
for ( i = 0; i < sglob->num_replicas; i++ ) {
|
||||||
|
|
@ -165,11 +156,7 @@ set_shutdown(int x)
|
||||||
RETSIGTYPE
|
RETSIGTYPE
|
||||||
do_nothing(int i)
|
do_nothing(int i)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LINUX_THREADS
|
(void) SIGNAL( LDAP_SIGUSR1, do_nothing );
|
||||||
(void) SIGNAL( SIGSTKFLT, do_nothing );
|
|
||||||
#else
|
|
||||||
(void) SIGNAL( SIGUSR1, do_nothing );
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,11 +45,7 @@ Ri_process(
|
||||||
int rc ;
|
int rc ;
|
||||||
char *errmsg;
|
char *errmsg;
|
||||||
|
|
||||||
#ifdef HAVE_LINUX_THREADS
|
(void) SIGNAL( LDAP_SIGUSR1, do_nothing );
|
||||||
(void) SIGNAL( SIGSTKFLT, do_nothing );
|
|
||||||
#else
|
|
||||||
(void) SIGNAL( SIGUSR1, do_nothing );
|
|
||||||
#endif
|
|
||||||
(void) SIGNAL( SIGPIPE, SIG_IGN );
|
(void) SIGNAL( SIGPIPE, SIG_IGN );
|
||||||
if ( ri == NULL ) {
|
if ( ri == NULL ) {
|
||||||
Debug( LDAP_DEBUG_ANY, "Error: Ri_process: ri == NULL!\n", 0, 0, 0 );
|
Debug( LDAP_DEBUG_ANY, "Error: Ri_process: ri == NULL!\n", 0, 0, 0 );
|
||||||
|
|
@ -149,13 +145,8 @@ Ri_wake(
|
||||||
if ( ri == NULL ) {
|
if ( ri == NULL ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef HAVE_LINUX_THREADS
|
pthread_kill( ri->ri_tid, LDAP_SIGUSR1 );
|
||||||
pthread_kill( ri->ri_tid, SIGSTKFLT );
|
(void) SIGNAL( LDAP_SIGUSR1, do_nothing );
|
||||||
(void) SIGNAL( SIGSTKFLT, do_nothing );
|
|
||||||
#else
|
|
||||||
pthread_kill( ri->ri_tid, SIGUSR1 );
|
|
||||||
(void) SIGNAL( SIGUSR1, do_nothing );
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue