Listener **slap_listeners = NULL;
-#define SLAPD_LISTEN 10
+#ifndef SLAPD_LISTEN_BACKLOG
+#define SLAPD_LISTEN_BACKLOG 1024
+#endif
static ber_socket_t wake_sds[2];
static int emfile;
static int waking;
-#define WAKE_LISTENER(w) \
-do { if (w && waking < 5) { waking++; tcp_write( wake_sds[1], "0", 1 ); } } while(0)
+#define WAKE_LISTENER(w) do { \
+ if ((w) && waking < 5) { waking++; tcp_write( wake_sds[1], "0", 1 ); } \
+ } while(0)
volatile sig_atomic_t slapd_shutdown = 0, slapd_gentle_shutdown = 0;
volatile sig_atomic_t slapd_abrupt_shutdown = 0;
#endif
#ifdef LDAP_PF_LOCAL
case AF_LOCAL:
- addrlen = sizeof(struct sockaddr_un);
- break;
+#ifdef LOCAL_CREDS
+ {
+ int one = 1;
+ setsockopt(l.sl_sd, 0, LOCAL_CREDS, &one, sizeof one);
+ }
+#endif
+ addrlen = sizeof(struct sockaddr_un);
+ break;
#endif
}
}
#endif
- if ( listen( slap_listeners[l]->sl_sd, SLAPD_LISTEN ) == -1 ) {
+ if ( listen( slap_listeners[l]->sl_sd, SLAPD_LISTEN_BACKLOG ) == -1 ) {
int err = sock_errno();
#ifdef LDAP_PF_INET6
}
ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
- if ( cat != NULL ) {
+ if ( cat && cat->tv_sec ) {
time_t diff = difftime( cat->tv_sec, now );
if ( diff == 0 )
diff = tdelta;
case 0: /* timeout - let threads run */
ebadf = 0;
+#ifndef HAVE_YIELDING_SELECT
Debug( LDAP_DEBUG_CONNS, "daemon: select timeout - yielding\n",
0, 0, 0 );
ldap_pvt_thread_yield();
+#endif
continue;
default: /* something happened - deal with it */
/* bypass the following tests if no descriptors left */
if ( ns <= 0 ) {
+#ifndef HAVE_YIELDING_SELECT
ldap_pvt_thread_yield();
+#endif
continue;
}
}
slapd_close( wd );
}
+ SLAP_EVENT_CLR_WRITE( wd );
}
for ( i = 0; nrfds > 0; i++ )
}
#endif /* SLAP_EVENTS_ARE_INDEXED */
+#ifndef HAVE_YIELDING_SELECT
ldap_pvt_thread_yield();
+#endif
}
if( slapd_shutdown == 1 ) {
- Debug( LDAP_DEBUG_TRACE,
+ Debug( LDAP_DEBUG_ANY,
"daemon: shutdown requested and initiated.\n",
0, 0, 0 );
} else if ( slapd_shutdown == 2 ) {
#ifdef HAVE_NT_SERVICE_MANAGER
- Debug( LDAP_DEBUG_TRACE,
+ Debug( LDAP_DEBUG_ANY,
"daemon: shutdown initiated by Service Manager.\n",
0, 0, 0);
#else /* !HAVE_NT_SERVICE_MANAGER */
- Debug( LDAP_DEBUG_TRACE,
+ Debug( LDAP_DEBUG_ANY,
"daemon: abnormal condition, shutdown initiated.\n",
0, 0, 0 );
#endif /* !HAVE_NT_SERVICE_MANAGER */
} else {
- Debug( LDAP_DEBUG_TRACE,
+ Debug( LDAP_DEBUG_ANY,
"daemon: no active streams, shutdown initiated.\n",
0, 0, 0 );
}