X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fdaemon.c;h=7dbfa2abf78c3b152adf75a101e3341c0718bd49;hb=412f44afa3e19d104e13b448f7db471048abfb8f;hp=863ca497d322f7102c71c021939e724df3424aeb;hpb=df38bf83e8babd8e53a661b986a48171975894b6;p=openldap diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index 863ca497d3..7dbfa2abf7 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -1,3 +1,10 @@ + +/* Revision history + * + * 5-Jun-96 hodges + * Added locking of new_conn_mutex when traversing the c[] array. + */ + #include #include #include @@ -48,7 +55,7 @@ static void set_shutdown(); static void do_nothing(); void -daemon( +slapd_daemon( int port ) { @@ -132,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 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 ); @@ -170,6 +185,8 @@ daemon( Debug( LDAP_DEBUG_CONNS, "listening for connections on %d, activity on:", tcps, 0, 0 ); + + pthread_mutex_lock( &new_conn_mutex ); for ( i = 0; i < dtblsize; i++ ) { if ( c[i].c_sb.sb_sd != -1 ) { FD_SET( c[i].c_sb.sb_sd, &readfds ); @@ -182,6 +199,7 @@ daemon( } } Debug( LDAP_DEBUG_CONNS, "\n", 0, 0, 0 ); + pthread_mutex_unlock( &new_conn_mutex ); zero.tv_sec = 0; zero.tv_usec = 0; @@ -231,7 +249,7 @@ daemon( } if ( ioctl( ns, FIONBIO, (caddr_t) &on ) == -1 ) { Debug( LDAP_DEBUG_ANY, - "FIONBIO ioctl on %d faled\n", ns, 0, 0 ); + "FIONBIO ioctl on %d failed\n", ns, 0, 0 ); } c[ns].c_sb.sb_sd = ns; Debug( LDAP_DEBUG_CONNS, "new connection on %d\n", ns, @@ -355,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 ); @@ -365,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 }