+
+/* Revision history
+ *
+ * 5-Jun-96 hodges
+ * Added locking of new_conn_mutex when traversing the c[] array.
+ */
+
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
static void do_nothing();
void
-daemon(
+slapd_daemon(
int port
)
{
#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++ ) {
}
(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 );
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 );
}
}
Debug( LDAP_DEBUG_CONNS, "\n", 0, 0, 0 );
+ pthread_mutex_unlock( &new_conn_mutex );
zero.tv_sec = 0;
zero.tv_usec = 0;
}
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,
{
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
}