mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-09 02:52:04 +08:00
integrated changed from rage.net glibc.patch
This commit is contained in:
parent
14b7b66f94
commit
f3e9bc606c
@ -33,7 +33,8 @@
|
||||
#include <termios.h>
|
||||
#endif /* defined( NeXT ) || defined( ultrix ) etc. */
|
||||
#endif /* !DOS */
|
||||
#if defined( aix ) || defined( __NetBSD__ )
|
||||
#if defined( aix ) || defined( __NetBSD__ ) \
|
||||
|| defined( __FreeBSD__ ) || defined( linux )
|
||||
#include <sys/ioctl.h>
|
||||
#endif /* aix || __NetBSD__ */
|
||||
#include <ctype.h>
|
||||
|
@ -160,6 +160,18 @@ typedef cond_t pthread_cond_t;
|
||||
#define pthread_attr_setdetachstate( a, b ) \
|
||||
pthread_attr_setdetach_np( a, b )
|
||||
|
||||
#else /* end dce pthreads */
|
||||
|
||||
#if defined( POSIX_THREADS )
|
||||
|
||||
#define _THREAD
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#define pthread_mutexattr_default NULL
|
||||
#define pthread_condattr_default NULL
|
||||
|
||||
#endif /* posix threads */
|
||||
#endif /* dce pthreads */
|
||||
#endif /* mit pthreads */
|
||||
#endif /* sunos5 */
|
||||
|
@ -120,7 +120,7 @@
|
||||
* Are sys_errlist and sys_nerr declared in stdio.h?
|
||||
*/
|
||||
#ifndef SYSERRLIST_IN_STDIO
|
||||
#if defined( freebsd ) || defined( linux )
|
||||
#if defined( freebsd ) || defined( __GLIBC__ ) && ( __GLIBC__ > 1 )
|
||||
#define SYSERRLIST_IN_STDIO
|
||||
#endif
|
||||
#endif
|
||||
|
@ -483,6 +483,16 @@ pthread_kill( pthread_t tid, int sig )
|
||||
kill( getpid(), sig );
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#if defined ( POSIX_THREADS )
|
||||
|
||||
void p_thread_yield( void )
|
||||
{
|
||||
sched_yield();
|
||||
}
|
||||
|
||||
#endif /* posix threads */
|
||||
#endif /* dce pthreads */
|
||||
#endif /* mit pthreads */
|
||||
#endif /* sunos5 lwp */
|
||||
|
@ -107,12 +107,15 @@ charray_dup( char **a )
|
||||
}
|
||||
|
||||
char **
|
||||
str2charray( char *str, char *brkstr )
|
||||
str2charray( char *str_in, char *brkstr )
|
||||
{
|
||||
char **res;
|
||||
char *s;
|
||||
int i;
|
||||
|
||||
/* protect the input string from strtok */
|
||||
char *str = strdup( str_in );
|
||||
|
||||
i = 1;
|
||||
for ( s = str; *s; s++ ) {
|
||||
if ( strchr( brkstr, *s ) != NULL ) {
|
||||
@ -128,5 +131,6 @@ str2charray( char *str, char *brkstr )
|
||||
}
|
||||
res[i] = NULL;
|
||||
|
||||
free( str );
|
||||
return( res );
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ connection_activity(
|
||||
|
||||
pthread_attr_init( &attr );
|
||||
pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED );
|
||||
if ( pthread_create( &arg->co_op->o_tid, attr,
|
||||
if ( pthread_create( &arg->co_op->o_tid, &attr,
|
||||
(void *) connection_operation, (void *) arg ) != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY, "pthread_create failed\n", 0, 0, 0 );
|
||||
} else {
|
||||
|
@ -139,8 +139,16 @@ daemon(
|
||||
}
|
||||
|
||||
(void) SIGNAL( SIGPIPE, SIG_IGN );
|
||||
#ifdef SIGSTKFLT
|
||||
(void) SIGNAL( SIGSTKFLT, (void *) do_nothing );
|
||||
#else
|
||||
(void) SIGNAL( SIGUSR1, (void *) do_nothing );
|
||||
#endif
|
||||
#ifdef SIGSTKFLT
|
||||
(void) SIGNAL( SIGUNUSED, (void *) set_shutdown );
|
||||
#else
|
||||
(void) SIGNAL( SIGUSR2, (void *) set_shutdown );
|
||||
#endif
|
||||
(void) SIGNAL( SIGTERM, (void *) set_shutdown );
|
||||
(void) SIGNAL( SIGINT, (void *) set_shutdown );
|
||||
(void) SIGNAL( SIGHUP, (void *) set_shutdown );
|
||||
@ -365,8 +373,16 @@ set_shutdown()
|
||||
{
|
||||
Debug( LDAP_DEBUG_ANY, "slapd got shutdown signal\n", 0, 0, 0 );
|
||||
slapd_shutdown = 1;
|
||||
#ifdef SIGSTKFLT
|
||||
pthread_kill( listener_tid, SIGSTKFLT );
|
||||
#else
|
||||
pthread_kill( listener_tid, SIGUSR1 );
|
||||
#endif
|
||||
#ifdef SIGUNUSED
|
||||
(void) SIGNAL( SIGUNUSED, (void *) set_shutdown );
|
||||
#else
|
||||
(void) SIGNAL( SIGUSR2, (void *) set_shutdown );
|
||||
#endif
|
||||
(void) SIGNAL( SIGTERM, (void *) set_shutdown );
|
||||
(void) SIGNAL( SIGINT, (void *) set_shutdown );
|
||||
(void) SIGNAL( SIGHUP, (void *) set_shutdown );
|
||||
@ -375,6 +391,10 @@ set_shutdown()
|
||||
static void
|
||||
do_nothing()
|
||||
{
|
||||
Debug( LDAP_DEBUG_TRACE, "slapd got SIGUSR1\n", 0, 0, 0 );
|
||||
Debug( LDAP_DEBUG_TRACE, "slapd got do_nothing signal\n", 0, 0, 0 );
|
||||
#ifdef SIGSTKFLT
|
||||
(void) SIGNAL( SIGSTKFLT, (void *) do_nothing );
|
||||
#else
|
||||
(void) SIGNAL( SIGUSR1, (void *) do_nothing );
|
||||
#endif
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "slap.h"
|
||||
#include "ldapconfig.h"
|
||||
|
||||
extern void daemon();
|
||||
extern void slapd_daemon();
|
||||
extern int lber_debug;
|
||||
|
||||
extern char Versionstr[];
|
||||
@ -184,7 +184,7 @@ main( argc, argv )
|
||||
pthread_attr_init( &attr );
|
||||
pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED );
|
||||
|
||||
if ( pthread_create( &listener_tid, attr, (void *) daemon,
|
||||
if ( pthread_create( &listener_tid, &attr, (void *) slapd_daemon,
|
||||
(void *) port ) != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY,
|
||||
"listener pthread_create failed\n", 0, 0, 0 );
|
||||
|
@ -121,7 +121,11 @@ send_ldap_result2(
|
||||
pthread_mutex_lock( &active_threads_mutex );
|
||||
active_threads--;
|
||||
conn->c_writewaiter = 1;
|
||||
#ifdef SIGSTKFLT
|
||||
pthread_kill( listener_tid, SIGSTKFLT );
|
||||
#else
|
||||
pthread_kill( listener_tid, SIGUSR1 );
|
||||
#endif
|
||||
pthread_cond_wait( &conn->c_wcv, &active_threads_mutex );
|
||||
pthread_mutex_unlock( &active_threads_mutex );
|
||||
|
||||
|
@ -77,12 +77,20 @@ fm(
|
||||
|
||||
/* Set up our signal handlers:
|
||||
* SIG{TERM,INT,HUP} causes a shutdown
|
||||
* SIGUSR1 - does nothing, used to wake up sleeping threads.
|
||||
* SIGUSR2 - causes slurpd to read its administrative interface file.
|
||||
* SIG(STKFLT|USR1) - does nothing, used to wake up sleeping threads.
|
||||
* SIG(UNUSED|USR2) - causes slurpd to read its administrative interface file.
|
||||
* (not yet implemented).
|
||||
*/
|
||||
#ifdef SIGSTKFLT
|
||||
(void) SIGNAL( SIGSTKFLT, (void *) do_nothing );
|
||||
#else
|
||||
(void) SIGNAL( SIGUSR1, (void *) do_nothing );
|
||||
#endif
|
||||
#ifdef SIGUNUSED
|
||||
(void) SIGNAL( SIGUNUSED, (void *) do_admin );
|
||||
#else
|
||||
(void) SIGNAL( SIGUSR2, (void *) do_admin );
|
||||
#endif
|
||||
(void) SIGNAL( SIGTERM, (void *) set_shutdown );
|
||||
(void) SIGNAL( SIGINT, (void *) set_shutdown );
|
||||
(void) SIGNAL( SIGHUP, (void *) set_shutdown );
|
||||
@ -160,7 +168,11 @@ set_shutdown()
|
||||
int i;
|
||||
|
||||
sglob->slurpd_shutdown = 1; /* set flag */
|
||||
#ifdef SIGSTKFLT
|
||||
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 */
|
||||
pthread_cond_broadcast( &(sglob->rq->rq_more) ); /* wake repl threads */
|
||||
for ( i = 0; i < sglob->num_replicas; i++ ) {
|
||||
@ -181,7 +193,11 @@ set_shutdown()
|
||||
void
|
||||
do_nothing()
|
||||
{
|
||||
#ifdef SIGSTKFLT
|
||||
(void) SIGNAL( SIGSTKFLT, (void *) do_nothing );
|
||||
#else
|
||||
(void) SIGNAL( SIGUSR1, (void *) do_nothing );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -121,7 +121,7 @@ main(
|
||||
* Start the main file manager thread (in fm.c).
|
||||
*/
|
||||
pthread_attr_init( &attr );
|
||||
if ( pthread_create( &(sglob->fm_tid), attr, (void *) fm, (void *) NULL )
|
||||
if ( pthread_create( &(sglob->fm_tid), &attr, (void *) fm, (void *) NULL )
|
||||
!= 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY, "file manager pthread_create failed\n",
|
||||
0, 0, 0 );
|
||||
|
@ -59,7 +59,7 @@ start_replica_thread(
|
||||
pthread_attr_init( &attr );
|
||||
pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED );
|
||||
|
||||
if ( pthread_create( &(ri->ri_tid), attr, (void *) replicate,
|
||||
if ( pthread_create( &(ri->ri_tid), &attr, (void *) replicate,
|
||||
(void *) ri ) != 0 ) {
|
||||
Debug( LDAP_DEBUG_ANY, "replica \"%s:%d\" pthread_create failed\n",
|
||||
ri->ri_hostname, ri->ri_port, 0 );
|
||||
|
@ -60,7 +60,11 @@ Ri_process(
|
||||
int rc ;
|
||||
char *errmsg;
|
||||
|
||||
#ifdef SIGSTKFLT
|
||||
(void) SIGNAL( SIGSTKFLT, (void *) do_nothing );
|
||||
#else
|
||||
(void) SIGNAL( SIGUSR1, (void *) do_nothing );
|
||||
#endif
|
||||
(void) SIGNAL( SIGPIPE, SIG_IGN );
|
||||
if ( ri == NULL ) {
|
||||
Debug( LDAP_DEBUG_ANY, "Error: Ri_process: ri == NULL!\n", 0, 0, 0 );
|
||||
@ -146,7 +150,8 @@ Ri_process(
|
||||
|
||||
|
||||
/*
|
||||
* Wake a replication thread which may be sleeping. Send it a SIGUSR1.
|
||||
* Wake a replication thread which may be sleeping.
|
||||
* Send it a SIG(STKFLT|USR1).
|
||||
*/
|
||||
static void
|
||||
Ri_wake(
|
||||
@ -156,8 +161,13 @@ Ri_wake(
|
||||
if ( ri == NULL ) {
|
||||
return;
|
||||
}
|
||||
#ifdef SIGSTKFLT
|
||||
pthread_kill( ri->ri_tid, SIGSTKFLT );
|
||||
(void) SIGNAL( SIGSTKFLT, (void *) do_nothing );
|
||||
#else
|
||||
pthread_kill( ri->ri_tid, SIGUSR1 );
|
||||
(void) SIGNAL( SIGUSR1, (void *) do_nothing );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user