X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fdaemon.c;h=7dbfa2abf78c3b152adf75a101e3341c0718bd49;hb=412f44afa3e19d104e13b448f7db471048abfb8f;hp=161fb79cf0e2bf6ce67b05be0ff4d7efba0a67ab;hpb=42e0d83cb3a1a1c5b25183f1ab74ce7edbe25de7;p=openldap diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index 161fb79cf0..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 ) { @@ -68,7 +75,12 @@ daemon( #else /* USE_SYSCONF */ dtblsize = getdtablesize(); #endif /* USE_SYSCONF */ - + /* + * Add greg@greg.rim.or.jp + */ + if(dtblsize > FD_SETSIZE) { + dtblsize = FD_SETSIZE; + } c = (Connection *) ch_calloc( 1, dtblsize * sizeof(Connection) ); for ( i = 0; i < dtblsize; i++ ) { @@ -127,9 +139,18 @@ 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 ); Debug( LDAP_DEBUG_ANY, "slapd starting\n", 0, 0, 0 ); @@ -164,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 ); @@ -176,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; @@ -225,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, @@ -349,15 +373,28 @@ 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 ); } 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 }