X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fmain.c;h=4d91ee7847d095323e15df0467a5209321b7a9bf;hb=a6883d270464bb74e86141435dc4324e5a5a6b6a;hp=dd7ecf0027a33e20ad5f5a530391c7d47c2bea68;hpb=03fcd92fe8e3d88a3f1cc7a0d84d683e07b705b6;p=openldap diff --git a/servers/slapd/main.c b/servers/slapd/main.c index dd7ecf0027..4d91ee7847 100644 --- a/servers/slapd/main.c +++ b/servers/slapd/main.c @@ -2,6 +2,7 @@ #include +#include #include #include #include @@ -48,12 +49,6 @@ static int cnvt_str2int(); #endif /* LOG_LOCAL4 */ -/* - * the server's name must be accessible from the daemon module, - * to construct the pid/args file names - */ -char *serverName = NULL; - static void usage( char *name ) @@ -75,8 +70,12 @@ main( int argc, char **argv ) Backend *be = NULL; FILE *fp = NULL; char *configfile; + char *serverName; #ifdef LOG_LOCAL4 + char *optstring = "d:f:ip:s:ul:"; int syslogUser = DEFAULT_SYSLOG_USER; +#else + char *optstring = "d:f:ip:s:u"; #endif configfile = SLAPD_DEFAULT_CONFIGFILE; @@ -84,7 +83,7 @@ main( int argc, char **argv ) g_argc = argc; g_argv = argv; - while ( (i = getopt( argc, argv, "d:f:ip:s:u" )) != EOF ) { + while ( (i = getopt( argc, argv, optstring )) != EOF ) { switch ( i ) { #ifdef LDAP_DEBUG case 'd': /* turn on debugging */ @@ -146,12 +145,10 @@ main( int argc, char **argv ) break; #ifdef LOG_LOCAL4 - case 'l': /* set syslog local user */ syslogUser = cnvt_str2int( optarg, syslog_types, DEFAULT_SYSLOG_USER ); break; - #endif case 'u': /* do udp */ @@ -194,20 +191,24 @@ main( int argc, char **argv ) 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 ); + time( &starttime ); - if ( pthread_create( &listener_tid, NULL, slapd_daemon, - (void *) port ) != 0 ) { + if ( status = ldap_pvt_thread_create( &listener_tid, 0, + slapd_daemon, (void *) port ) != 0 ) + { Debug( LDAP_DEBUG_ANY, - "listener pthread_create failed\n", 0, 0, 0 ); + "listener ldap_pvt_thread_create failed (%d)\n", status, 0, 0 ); exit( 1 ); } -#ifdef HAVE_PHREADS_FINAL - pthread_join( listener_tid, (void *) NULL ); -#else - pthread_join( listener_tid, (void *) &status ); -#endif + ldap_pvt_thread_join( listener_tid, (void *) NULL ); return 0; @@ -230,9 +231,9 @@ main( int argc, char **argv ) c.c_sb.sb_ber.ber_buf = NULL; c.c_sb.sb_ber.ber_ptr = NULL; c.c_sb.sb_ber.ber_end = NULL; - pthread_mutex_init( &c.c_dnmutex, pthread_mutexattr_default ); - pthread_mutex_init( &c.c_opsmutex, pthread_mutexattr_default ); - pthread_mutex_init( &c.c_pdumutex, pthread_mutexattr_default ); + ldap_pvt_thread_mutex_init( &c.c_dnmutex ); + ldap_pvt_thread_mutex_init( &c.c_opsmutex ); + ldap_pvt_thread_mutex_init( &c.c_pdumutex ); #ifdef notdefcldap c.c_sb.sb_addrs = (void **) saddrlist; c.c_sb.sb_fromaddr = &faddr; @@ -261,9 +262,9 @@ main( int argc, char **argv ) ber_init( &ber, 0 ); while ( (tag = ber_get_next( &c.c_sb, &len, &ber )) == LDAP_TAG_MESSAGE ) { - pthread_mutex_lock( ¤ttime_mutex ); + ldap_pvt_thread_mutex_lock( ¤ttime_mutex ); time( ¤ttime ); - pthread_mutex_unlock( ¤ttime_mutex ); + ldap_pvt_thread_mutex_unlock( ¤ttime_mutex ); if ( (tag = ber_get_int( &ber, &msgid )) != LDAP_TAG_MSGID ) {