3 * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
13 #include <ac/socket.h>
14 #include <ac/string.h>
16 #include <ac/unistd.h>
19 #include "ldap_pvt_thread.h"
26 int allow_severity = LOG_INFO;
27 int deny_severity = LOG_NOTICE;
28 #endif /* TCP Wrappers */
32 /* this should go in <ldap.h> as soon as it is accepted */
33 #define LDAPI_MOD_URLEXT "x-mod"
34 #endif /* LDAP_PF_LOCAL */
38 ber_socket_t dtblsize;
40 Listener **slap_listeners = NULL;
42 #define SLAPD_LISTEN 10
44 static ber_socket_t wake_sds[2];
48 #define WAKE_LISTENER(w) \
49 ((w && !waking) ? tcp_write( wake_sds[1], "0", 1 ), waking=1 : 0)
51 #define WAKE_LISTENER(w) \
52 do { if (w) tcp_write( wake_sds[1], "0", 1 ); } while(0)
58 volatile sig_atomic_t slapd_shutdown = 0;
60 static struct slap_daemon {
61 ldap_pvt_thread_mutex_t sd_mutex;
66 /* In winsock, accept() returns values higher than dtblsize
67 so don't bother with this optimization */
80 * SLP related functions
84 #define LDAP_SRVTYPE_PREFIX "service:ldap://"
85 #define LDAPS_SRVTYPE_PREFIX "service:ldaps://"
86 static char** slapd_srvurls = NULL;
87 static SLPHandle slapd_hslp = 0;
89 void slapd_slp_init( const char* urls ) {
92 slapd_srvurls = str2charray( urls, " " );
94 if( slapd_srvurls == NULL ) return;
96 /* find and expand INADDR_ANY URLs */
97 for( i=0; slapd_srvurls[i] != NULL; i++ ) {
98 if( strcmp( slapd_srvurls[i], "ldap:///" ) == 0) {
99 char *host = ldap_pvt_get_fqdn( NULL );
100 if ( host != NULL ) {
101 slapd_srvurls[i] = (char *) realloc( slapd_srvurls[i],
103 sizeof( LDAP_SRVTYPE_PREFIX ) );
104 strcpy( slap_strcopy(slapd_srvurls[i],
105 LDAP_SRVTYPE_PREFIX ), host );
110 } else if ( strcmp( slapd_srvurls[i], "ldaps:///" ) == 0) {
111 char *host = ldap_pvt_get_fqdn( NULL );
112 if ( host != NULL ) {
113 slapd_srvurls[i] = (char *) realloc( slapd_srvurls[i],
115 sizeof( LDAPS_SRVTYPE_PREFIX ) );
116 strcpy( slap_strcopy(slapd_srvurls[i],
117 LDAPS_SRVTYPE_PREFIX ), host );
124 /* open the SLP handle */
125 SLPOpen( "en", 0, &slapd_hslp );
128 void slapd_slp_deinit() {
129 if( slapd_srvurls == NULL ) return;
131 charray_free( slapd_srvurls );
132 slapd_srvurls = NULL;
134 /* close the SLP handle */
135 SLPClose( slapd_hslp );
138 void slapd_slp_regreport(
146 void slapd_slp_reg() {
149 for( i=0; slapd_srvurls[i] != NULL; i++ ) {
150 if( strncmp( slapd_srvurls[i], LDAP_SRVTYPE_PREFIX,
151 sizeof( LDAP_SRVTYPE_PREFIX ) - 1 ) == 0 ||
152 strncmp( slapd_srvurls[i], LDAPS_SRVTYPE_PREFIX,
153 sizeof( LDAPS_SRVTYPE_PREFIX ) - 1 ) == 0 )
157 SLP_LIFETIME_MAXIMUM,
167 void slapd_slp_dereg() {
170 for( i=0; slapd_srvurls[i] != NULL; i++ ) {
171 SLPDereg( slapd_hslp,
177 #endif /* HAVE_SLP */
180 * Add a descriptor to daemon control
182 static void slapd_add(ber_socket_t s) {
183 ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
185 assert( !FD_ISSET( s, &slap_daemon.sd_actives ));
186 assert( !FD_ISSET( s, &slap_daemon.sd_readers ));
187 assert( !FD_ISSET( s, &slap_daemon.sd_writers ));
190 if (s >= slap_daemon.sd_nfds) {
191 slap_daemon.sd_nfds = s + 1;
195 FD_SET( s, &slap_daemon.sd_actives );
196 FD_SET( s, &slap_daemon.sd_readers );
199 LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1,
200 "slapd_add: added %ld%s%s\n",
202 FD_ISSET(s, &slap_daemon.sd_readers) ? "r" : "",
203 FD_ISSET(s, &slap_daemon.sd_writers) ? "w" : "" ));
205 Debug( LDAP_DEBUG_CONNS, "daemon: added %ld%s%s\n",
207 FD_ISSET(s, &slap_daemon.sd_readers) ? "r" : "",
208 FD_ISSET(s, &slap_daemon.sd_writers) ? "w" : "" );
210 ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
214 * Remove the descriptor from daemon control
216 void slapd_remove(ber_socket_t s, int wake) {
217 ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
220 LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1,
221 "slapd_remove: removing %ld%s%s\n",
223 FD_ISSET(s, &slap_daemon.sd_readers) ? "r" : "",
224 FD_ISSET(s, &slap_daemon.sd_writers) ? "w" : "" ));
226 Debug( LDAP_DEBUG_CONNS, "daemon: removing %ld%s%s\n",
228 FD_ISSET(s, &slap_daemon.sd_readers) ? "r" : "",
229 FD_ISSET(s, &slap_daemon.sd_writers) ? "w" : "" );
231 FD_CLR( s, &slap_daemon.sd_actives );
232 FD_CLR( s, &slap_daemon.sd_readers );
233 FD_CLR( s, &slap_daemon.sd_writers );
235 ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
239 void slapd_clr_write(ber_socket_t s, int wake) {
240 ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
242 assert( FD_ISSET( s, &slap_daemon.sd_actives) );
243 FD_CLR( s, &slap_daemon.sd_writers );
245 ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
249 void slapd_set_write(ber_socket_t s, int wake) {
250 ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
252 assert( FD_ISSET( s, &slap_daemon.sd_actives) );
253 if (!FD_ISSET(s, &slap_daemon.sd_writers))
254 FD_SET( (unsigned) s, &slap_daemon.sd_writers );
256 ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
260 void slapd_clr_read(ber_socket_t s, int wake) {
261 ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
263 assert( FD_ISSET( s, &slap_daemon.sd_actives) );
264 FD_CLR( s, &slap_daemon.sd_readers );
266 ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
270 void slapd_set_read(ber_socket_t s, int wake) {
271 ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
273 assert( FD_ISSET( s, &slap_daemon.sd_actives) );
274 if (!FD_ISSET(s, &slap_daemon.sd_readers))
275 FD_SET( s, &slap_daemon.sd_readers );
277 ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
281 static void slapd_close(ber_socket_t s) {
283 LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1,
284 "slapd_close: closing %ld\n", (long)s ));
286 Debug( LDAP_DEBUG_CONNS, "daemon: closing %ld\n",
292 static void slap_free_listener_addresses(struct sockaddr **sal)
294 struct sockaddr **sap;
300 for (sap = sal; *sap != NULL; sap++) {
308 static int get_url_perms(
320 for ( i = 0; exts[ i ]; i++ ) {
321 char *type = exts[ i ];
324 if ( type[ 0 ] == '!' ) {
329 if ( strncasecmp( type, LDAPI_MOD_URLEXT "=", sizeof(LDAPI_MOD_URLEXT "=") - 1 ) == 0 ) {
330 char *value = type + sizeof(LDAPI_MOD_URLEXT "=") - 1;
334 if ( strlen(value) != 3 ) {
338 for ( j = 0; j < 3; j++ ) {
340 = { S_IRWXU, S_IRWXG, S_IRWXO };
342 switch ( value[ j ] ) {
362 #endif /* LDAP_PF_LOCAL */
364 /* port = 0 indicates AF_LOCAL */
365 static int slap_get_listener_addresses(
368 struct sockaddr ***sal)
370 struct sockaddr **sap;
374 *sal = ch_malloc(2 * sizeof(void *));
380 *sap = ch_malloc(sizeof(struct sockaddr_un));
386 (sizeof(((struct sockaddr_un *)*sap)->sun_path) - 1) ) {
388 LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
389 "slap_get_listener_addresses: domain socket path (%s) too long in URL\n",
392 Debug( LDAP_DEBUG_ANY,
393 "daemon: domain socket path (%s) too long in URL",
399 (void)memset( (void *)*sap, '\0', sizeof(struct sockaddr_un) );
400 (*sap)->sa_family = AF_LOCAL;
401 strcpy( ((struct sockaddr_un *)*sap)->sun_path, host );
405 #ifdef HAVE_GETADDRINFO
406 struct addrinfo hints, *res, *sai;
410 memset( &hints, '\0', sizeof(hints) );
411 hints.ai_flags = AI_PASSIVE;
412 hints.ai_socktype = SOCK_STREAM;
413 hints.ai_family = AF_UNSPEC;
414 snprintf(serv, sizeof serv, "%d", port);
416 if ( (err = getaddrinfo(host, serv, &hints, &res)) ) {
418 LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
419 "slap_get_listener_addresses: getaddrinfo failed: %s\n",
420 AC_GAI_STRERROR(err) ));
422 Debug( LDAP_DEBUG_ANY, "daemon: getaddrinfo failed: %s\n",
423 AC_GAI_STRERROR(err), 0, 0);
429 for (n=2; (sai = sai->ai_next) != NULL; n++) {
432 *sal = ch_calloc(n, sizeof(void *));
440 for ( sai=res; sai; sai=sai->ai_next ) {
441 if( sai->ai_addr == NULL ) {
443 LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
444 "slap_get_listener_addresses: "
445 "getaddrinfo ai_addr is NULL?\n" ));
447 Debug( LDAP_DEBUG_ANY, "slap_get_listener_addresses: "
448 "getaddrinfo ai_addr is NULL?\n", 0, 0, 0 );
454 switch (sai->ai_family) {
455 # ifdef LDAP_PF_INET6
457 *sap = ch_malloc(sizeof(struct sockaddr_in6));
462 *(struct sockaddr_in6 *)*sap =
463 *((struct sockaddr_in6 *)sai->ai_addr);
467 *sap = ch_malloc(sizeof(struct sockaddr_in));
472 *(struct sockaddr_in *)*sap =
473 *((struct sockaddr_in *)sai->ai_addr);
481 (*sap)->sa_family = sai->ai_family;
491 if ( host == NULL ) {
492 in.s_addr = htonl(INADDR_ANY);
494 } else if ( !inet_aton( host, &in ) ) {
495 struct hostent *he = gethostbyname( host );
498 LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
499 "slap_get_listener_addresses: invalid host %s\n",
502 Debug( LDAP_DEBUG_ANY,
503 "daemon: invalid host %s", host, 0, 0);
507 AC_MEMCPY( &in, he->h_addr, sizeof( in ) );
510 *sal = ch_malloc(2 * sizeof(void *));
516 *sap = ch_malloc(sizeof(struct sockaddr_in));
522 (void)memset( (void *)*sap, '\0', sizeof(struct sockaddr_in) );
523 (*sap)->sa_family = AF_INET;
524 ((struct sockaddr_in *)*sap)->sin_port = htons(port);
525 ((struct sockaddr_in *)*sap)->sin_addr = in;
532 slap_free_listener_addresses(*sal);
536 static Listener * slap_open_listener(
544 int err, addrlen = 0;
545 struct sockaddr **sal, **psal;
546 int socktype = SOCK_STREAM; /* default to COTS */
548 mode_t perms = S_IRWXU;
552 rc = ldap_url_parse( url, &lud );
554 if( rc != LDAP_URL_SUCCESS ) {
556 LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
557 "slap_open_listener: listen URL \"%s\" parse error %d\n",
560 Debug( LDAP_DEBUG_ANY,
561 "daemon: listen URL \"%s\" parse error=%d\n",
568 if( ldap_pvt_url_scheme2tls( lud->lud_scheme ) ) {
570 LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
571 "slap_open_listener: TLS is not supported (%s)\n",
574 Debug( LDAP_DEBUG_ANY,
575 "daemon: TLS not supported (%s)\n",
578 ldap_free_urldesc( lud );
582 if(! lud->lud_port ) {
583 lud->lud_port = LDAP_PORT;
587 l.sl_is_tls = ldap_pvt_url_scheme2tls( lud->lud_scheme );
589 if(! lud->lud_port ) {
590 lud->lud_port = l.sl_is_tls ? LDAPS_PORT : LDAP_PORT;
594 port = (unsigned short) lud->lud_port;
596 tmp = ldap_pvt_url_scheme2proto(lud->lud_scheme);
597 if ( tmp == LDAP_PROTO_IPC ) {
599 if ( lud->lud_host == NULL || lud->lud_host[0] == '\0' ) {
600 err = slap_get_listener_addresses(LDAPI_SOCK, 0, &sal);
602 err = slap_get_listener_addresses(lud->lud_host, 0, &sal);
605 if ( lud->lud_exts ) {
606 err = get_url_perms( lud->lud_exts, &perms, &crit );
611 LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
612 "slap_open_listener: URL scheme is not supported: %s\n",
615 Debug( LDAP_DEBUG_ANY, "daemon: URL scheme not supported: %s",
618 ldap_free_urldesc( lud );
622 #ifdef LDAP_CONNECTIONLESS
623 l.sl_is_udp = ( tmp == LDAP_PROTO_UDP );
625 if( lud->lud_host == NULL || lud->lud_host[0] == '\0'
626 || strcmp(lud->lud_host, "*") == 0 )
628 err = slap_get_listener_addresses(NULL, port, &sal);
630 err = slap_get_listener_addresses(lud->lud_host, port, &sal);
634 ldap_free_urldesc( lud );
640 while ( *sal != NULL ) {
641 switch( (*sal)->sa_family ) {
654 #ifdef LDAP_CONNECTIONLESS
656 socktype = SOCK_DGRAM;
658 l.sl_sd = socket( (*sal)->sa_family, socktype, 0);
659 if ( l.sl_sd == AC_SOCKET_INVALID ) {
660 int err = sock_errno();
662 LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
663 "slap_open_listener: socket() failed errno=%d (%s)\n",
664 err, sock_errstr(err) ));
666 Debug( LDAP_DEBUG_ANY,
667 "daemon: socket() failed errno=%d (%s)\n", err,
668 sock_errstr(err), 0 );
674 if ( l.sl_sd >= dtblsize ) {
676 LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
677 "slap_open_listener: listener descriptor %ld is too great %ld\n",
678 (long)l.sl_sd, (long)dtblsize ));
680 Debug( LDAP_DEBUG_ANY,
681 "daemon: listener descriptor %ld is too great %ld\n",
682 (long) l.sl_sd, (long) dtblsize, 0 );
684 tcp_close( l.sl_sd );
690 if ( (*sal)->sa_family == AF_LOCAL ) {
691 unlink ( ((struct sockaddr_un *)*sal)->sun_path );
696 /* enable address reuse */
698 rc = setsockopt( l.sl_sd, SOL_SOCKET, SO_REUSEADDR,
699 (char *) &tmp, sizeof(tmp) );
700 if ( rc == AC_SOCKET_ERROR ) {
701 int err = sock_errno();
703 LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
704 "slap_open_listener: setsockopt( %ld, SO_REUSEADDR ) failed errno %d (%s)\n",
705 (long)l.sl_sd, err, sock_errstr(err) ));
707 Debug( LDAP_DEBUG_ANY,
708 "slapd(%ld): setsockopt(SO_REUSEADDR) failed errno=%d (%s)\n",
709 (long) l.sl_sd, err, sock_errstr(err) );
715 switch( (*sal)->sa_family ) {
717 addrlen = sizeof(struct sockaddr_in);
721 addrlen = sizeof(struct sockaddr_in6);
726 addrlen = sizeof(struct sockaddr_un);
731 if (!bind(l.sl_sd, *sal, addrlen))
735 LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
736 "slap_open_listener: bind(%ld) failed errno=%d (%s)\n",
737 (long)l.sl_sd, err, sock_errstr(err) ));
739 Debug( LDAP_DEBUG_ANY, "daemon: bind(%ld) failed errno=%d (%s)\n",
740 (long) l.sl_sd, err, sock_errstr(err) );
742 tcp_close( l.sl_sd );
744 } /* while ( *sal != NULL ) */
746 if ( *sal == NULL ) {
748 LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
749 "slap_open_listener: bind(%ld) failed.\n", (long)l.sl_sd ));
751 Debug( LDAP_DEBUG_ANY, "daemon: bind(%ld) failed\n",
752 (long) l.sl_sd, 0, 0 );
754 slap_free_listener_addresses(psal);
758 switch ( (*sal)->sa_family ) {
761 char *addr = ((struct sockaddr_un *)*sal)->sun_path;
762 if ( chmod( addr, perms ) < 0 && crit ) {
763 int err = sock_errno();
765 LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
766 "slap_open_listener: fchmod(%ld) failed errno=%d (%s)\n",
767 (long)l.sl_sd, err, sock_errstr(err) ));
769 Debug( LDAP_DEBUG_ANY, "daemon: fchmod(%ld) failed errno=%d (%s)",
770 (long) l.sl_sd, err, sock_errstr(err) );
772 tcp_close( l.sl_sd );
773 slap_free_listener_addresses(psal);
776 l.sl_name = ch_malloc( strlen(addr) + sizeof("PATH=") );
777 sprintf( l.sl_name, "PATH=%s", addr );
779 #endif /* LDAP_PF_LOCAL */
783 #if defined( HAVE_GETADDRINFO ) && defined( HAVE_INET_NTOP )
784 char addr[INET_ADDRSTRLEN];
785 inet_ntop( AF_INET, &((struct sockaddr_in *)*sal)->sin_addr,
786 addr, sizeof(addr) );
789 s = inet_ntoa( ((struct sockaddr_in *) *sal)->sin_addr );
791 port = ntohs( ((struct sockaddr_in *)*sal) ->sin_port );
792 l.sl_name = ch_malloc( sizeof("IP=255.255.255.255:65535") );
793 sprintf( l.sl_name, "IP=%s:%d",
794 s != NULL ? s : "unknown" , port );
799 char addr[INET6_ADDRSTRLEN];
800 inet_ntop( AF_INET6, &((struct sockaddr_in6 *)*sal)->sin6_addr,
802 port = ntohs( ((struct sockaddr_in6 *)*sal)->sin6_port );
803 l.sl_name = ch_malloc( strlen(addr) + sizeof("IP= 65535") );
804 sprintf( l.sl_name, "IP=%s %d", addr, port );
806 #endif /* LDAP_PF_INET6 */
810 LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
811 "slap_open_listener: unsupported address family (%d)\n",
812 (int)(*sal)->sa_family ));
814 Debug( LDAP_DEBUG_ANY, "daemon: unsupported address family (%d)\n",
815 (int) (*sal)->sa_family, 0, 0 );
820 slap_free_listener_addresses(psal);
822 l.sl_url = ch_strdup( url );
823 li = ch_malloc( sizeof( Listener ) );
827 LDAP_LOG(( "connection", LDAP_LEVEL_RESULTS,
828 "slap_open_listener: daemon initialzed %s\n", l.sl_url ));
830 Debug( LDAP_DEBUG_TRACE, "daemon: initialized %s\n",
836 static int sockinit(void);
837 static int sockdestroy(void);
839 int slapd_daemon_init( const char *urls )
845 LDAP_LOG(( "connection", LDAP_LEVEL_ARGS,
846 "slapd_daemon_init: %s\n",
847 urls ? urls : "<null>" ));
849 Debug( LDAP_DEBUG_ARGS, "daemon_init: %s\n",
850 urls ? urls : "<null>", 0, 0 );
852 if( (rc = sockinit()) != 0 ) {
857 dtblsize = sysconf( _SC_OPEN_MAX );
858 #elif HAVE_GETDTABLESIZE
859 dtblsize = getdtablesize();
861 dtblsize = FD_SETSIZE;
865 if(dtblsize > FD_SETSIZE) {
866 dtblsize = FD_SETSIZE;
868 #endif /* !FD_SETSIZE */
870 /* open a pipe (or something equivalent connected to itself).
871 * we write a byte on this fd whenever we catch a signal. The main
872 * loop will be select'ing on this socket, and will wake up when
875 if( (rc = lutil_pair( wake_sds )) < 0 ) {
877 LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
878 "slap_daemon_init: lutil_pair() failed rc=%d\n", rc ));
880 Debug( LDAP_DEBUG_ANY,
881 "daemon: lutil_pair() failed rc=%d\n", rc, 0, 0 );
886 FD_ZERO( &slap_daemon.sd_readers );
887 FD_ZERO( &slap_daemon.sd_writers );
893 u = str2charray( urls, " " );
895 if( u == NULL || u[0] == NULL ) {
897 LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
898 "slap_daemon_init: no urls (%s) provided.\n", urls ));
900 Debug( LDAP_DEBUG_ANY, "daemon_init: no urls (%s) provided.\n",
906 for( i=0; u[i] != NULL; i++ ) {
908 LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1,
909 "slap_daemon_init: listen on %s\n.", u[i] ));
911 Debug( LDAP_DEBUG_TRACE, "daemon_init: listen on %s\n",
918 LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
919 "slap_daemon_init: no listeners to open (%s)\n", urls ));
921 Debug( LDAP_DEBUG_ANY, "daemon_init: no listeners to open (%s)\n",
929 LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
930 "slap_daemon_init: %d listeners to open...\n", i ));
932 Debug( LDAP_DEBUG_TRACE, "daemon_init: %d listeners to open...\n",
935 slap_listeners = ch_malloc( (i+1)*sizeof(Listener *) );
937 for(i = 0; u[i] != NULL; i++ ) {
938 slap_listeners[i] = slap_open_listener( u[i] );
940 if( slap_listeners[i] == NULL ) {
945 slap_listeners[i] = NULL;
948 LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1,
949 "slap_daemon_init: %d listeners opened\n", i ));
951 Debug( LDAP_DEBUG_TRACE, "daemon_init: %d listeners opened\n",
956 slapd_slp_init( urls );
961 ldap_pvt_thread_mutex_init( &slap_daemon.sd_mutex );
967 slapd_daemon_destroy(void)
969 connections_destroy();
970 tcp_close( wake_sds[1] );
971 tcp_close( wake_sds[0] );
989 time_t last_idle_check = 0;
992 if ( global_idletimeout > 0 ) {
993 last_idle_check = slap_get_time();
995 for ( l = 0; slap_listeners[l] != NULL; l++ ) {
996 if ( slap_listeners[l]->sl_sd == AC_SOCKET_INVALID )
998 #ifdef LDAP_CONNECTIONLESS
999 /* Since this is connectionless, the data port is the
1000 * listening port. The listen() and accept() calls
1003 if ( slap_listeners[l]->sl_is_udp )
1005 slapd_add( slap_listeners[l]->sl_sd );
1010 if ( listen( slap_listeners[l]->sl_sd, SLAPD_LISTEN ) == -1 ) {
1011 int err = sock_errno();
1013 LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
1014 "slapd_daemon_task: listen( %s, 5 ) failed errno=%d (%s)\n",
1015 slap_listeners[l]->sl_url, err, sock_errstr(err) ));
1017 Debug( LDAP_DEBUG_ANY,
1018 "daemon: listen(%s, 5) failed errno=%d (%s)\n",
1019 slap_listeners[l]->sl_url, err,
1022 return( (void*)-1 );
1025 slapd_add( slap_listeners[l]->sl_sd );
1028 #ifdef HAVE_NT_SERVICE_MANAGER
1029 if ( started_event != NULL ) {
1030 ldap_pvt_thread_cond_signal( &started_event );
1033 /* initialization complete. Here comes the loop. */
1035 while ( !slapd_shutdown ) {
1040 #define SLAPD_EBADF_LIMIT 16
1044 #define SLAPD_IDLE_CHECK_LIMIT 4
1052 #if defined(SLAPD_RLOOKUPS)
1055 struct timeval zero;
1056 struct timeval *tvp;
1059 now = slap_get_time();
1060 connections_timeout_idle( now );
1062 else if ( global_idletimeout > 0 ) {
1063 now = slap_get_time();
1064 if ( difftime( last_idle_check+global_idletimeout/SLAPD_IDLE_CHECK_LIMIT, now ) < 0 ) {
1065 connections_timeout_idle( now );
1069 FD_ZERO( &writefds );
1070 FD_ZERO( &readfds );
1075 ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
1077 #ifdef FD_SET_MANUAL_COPY
1078 for( s = 0; s < nfds; s++ ) {
1079 if(FD_ISSET( &slap_sd_readers, s )) {
1080 FD_SET( s, &readfds );
1082 if(FD_ISSET( &slap_sd_writers, s )) {
1083 FD_SET( s, &writefds );
1087 AC_MEMCPY( &readfds, &slap_daemon.sd_readers, sizeof(fd_set) );
1088 AC_MEMCPY( &writefds, &slap_daemon.sd_writers, sizeof(fd_set) );
1090 assert(!FD_ISSET(wake_sds[0], &readfds));
1091 FD_SET( wake_sds[0], &readfds );
1093 for ( l = 0; slap_listeners[l] != NULL; l++ ) {
1094 if ( slap_listeners[l]->sl_sd == AC_SOCKET_INVALID )
1096 if (!FD_ISSET(slap_listeners[l]->sl_sd, &readfds))
1097 FD_SET( slap_listeners[l]->sl_sd, &readfds );
1100 #ifndef HAVE_WINSOCK
1101 nfds = slap_daemon.sd_nfds;
1106 ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
1108 at = ldap_pvt_thread_pool_backload(&connection_pool);
1110 #if defined( HAVE_YIELDING_SELECT ) || defined( NO_THREADS )
1113 tvp = at ? &zero : NULL;
1116 for ( l = 0; slap_listeners[l] != NULL; l++ ) {
1117 if ( slap_listeners[l]->sl_sd == AC_SOCKET_INVALID )
1121 LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1,
1122 "slapd_daemon_task: select: listen=%d active_threads=%d tvp=%s\n",
1123 slap_listeners[l]->sl_sd, at, tvp == NULL ? "NULL" : "zero" ));
1125 Debug( LDAP_DEBUG_CONNS,
1126 "daemon: select: listen=%d active_threads=%d tvp=%s\n",
1127 slap_listeners[l]->sl_sd, at,
1128 tvp == NULL ? "NULL" : "zero" );
1132 switch(ns = select( nfds, &readfds,
1134 /* don't pass empty fd_set */
1135 ( writefds.fd_count > 0 ? &writefds : NULL ),
1141 case -1: { /* failure - try again */
1142 int err = sock_errno();
1146 /* you'd think this would be EBADF */
1147 || err == WSAENOTSOCK
1150 if (++ebadf < SLAPD_EBADF_LIMIT)
1154 if( err != EINTR ) {
1156 LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
1157 "slapd_daemon_task: select failed (%d): %s\n",
1158 err, sock_errstr(err) ));
1160 Debug( LDAP_DEBUG_CONNS,
1161 "daemon: select failed (%d): %s\n",
1162 err, sock_errstr(err), 0 );
1169 case 0: /* timeout - let threads run */
1172 LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL2,
1173 "slapd_daemon_task: select timeout - yielding\n" ));
1175 Debug( LDAP_DEBUG_CONNS, "daemon: select timeout - yielding\n",
1178 ldap_pvt_thread_yield();
1181 default: /* something happened - deal with it */
1182 if( slapd_shutdown ) continue;
1186 LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL2,
1187 "slapd_daemon_task: activity on %d descriptors\n", ns ));
1189 Debug( LDAP_DEBUG_CONNS, "daemon: activity on %d descriptors\n",
1195 if( FD_ISSET( wake_sds[0], &readfds ) ) {
1197 tcp_read( wake_sds[0], c, sizeof(c) );
1204 for ( l = 0; slap_listeners[l] != NULL; l++ ) {
1206 socklen_t len = sizeof(from);
1209 char *authid = NULL;
1211 char *dnsname = NULL;
1213 #ifdef LDAP_PF_LOCAL
1214 char peername[MAXPATHLEN + sizeof("PATH=")];
1215 #elif defined(LDAP_PF_INET6)
1216 char peername[sizeof("IP=ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff 65535")];
1218 char peername[sizeof("IP=255.255.255.255:65336")];
1219 #endif /* LDAP_PF_LOCAL */
1223 if ( slap_listeners[l]->sl_sd == AC_SOCKET_INVALID )
1226 if ( !FD_ISSET( slap_listeners[l]->sl_sd, &readfds ) )
1229 #ifdef LDAP_CONNECTIONLESS
1230 if ( slap_listeners[l]->sl_is_udp )
1232 /* The first time we receive a query, we set this
1233 * up as a "connection". It remains open for the life
1236 if ( slap_listeners[l]->sl_is_udp < 2 )
1238 id = connection_init(
1239 slap_listeners[l]->sl_sd,
1240 slap_listeners[l]->sl_url, "", "",
1241 slap_listeners[l]->sl_name,
1243 slap_listeners[l]->sl_is_udp++;
1249 s = accept( slap_listeners[l]->sl_sd,
1250 (struct sockaddr *) &from, &len );
1251 if ( s == AC_SOCKET_INVALID ) {
1252 int err = sock_errno();
1255 if( err == EMFILE ) {
1260 if( err == ENFILE ) {
1270 LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
1271 "slapd_daemon_task: accept(%ld) failed errno=%d (%s)\n",
1272 (long)slap_listeners[l]->sl_sd, err, sock_errstr(err) ));
1274 Debug( LDAP_DEBUG_ANY,
1275 "daemon: accept(%ld) failed errno=%d (%s)\n",
1276 (long) slap_listeners[l]->sl_sd, err,
1280 /* prevent busy loop */
1282 if( emfile % 4 == 3 ) usleep( 250 );
1284 if( emfile % 8 == 7 ) sleep( 1 );
1288 ldap_pvt_thread_yield();
1293 #ifndef HAVE_WINSOCK
1294 /* make sure descriptor number isn't too great */
1295 if ( s >= dtblsize ) {
1297 LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
1298 "slapd_daemon_task: %ld beyond descriptor table size %ld\n",
1299 (long)s, (long)dtblsize ));
1301 Debug( LDAP_DEBUG_ANY,
1302 "daemon: %ld beyond descriptor table size %ld\n",
1303 (long) s, (long) dtblsize, 0 );
1307 ldap_pvt_thread_yield();
1313 ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
1315 /* newly accepted stream should not be in any of the FD SETS */
1316 assert( !FD_ISSET( s, &slap_daemon.sd_actives) );
1317 assert( !FD_ISSET( s, &slap_daemon.sd_readers) );
1318 assert( !FD_ISSET( s, &slap_daemon.sd_writers) );
1320 ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
1323 #if defined( SO_KEEPALIVE ) || defined( TCP_NODELAY )
1324 #ifdef LDAP_PF_LOCAL
1325 /* for IPv4 and IPv6 sockets only */
1326 if ( from.sa_addr.sa_family != AF_LOCAL )
1327 #endif /* LDAP_PF_LOCAL */
1332 /* enable keep alives */
1334 rc = setsockopt( s, SOL_SOCKET, SO_KEEPALIVE,
1335 (char *) &tmp, sizeof(tmp) );
1336 if ( rc == AC_SOCKET_ERROR ) {
1337 int err = sock_errno();
1339 LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
1340 "slapd_daemon_task: setsockopt( %ld, SO_KEEPALIVE) failed errno=%d (%s)\n",
1341 (long)s, err, sock_errstr(err) ));
1343 Debug( LDAP_DEBUG_ANY,
1344 "slapd(%ld): setsockopt(SO_KEEPALIVE) failed "
1345 "errno=%d (%s)\n", (long) s, err, sock_errstr(err) );
1350 /* enable no delay */
1352 rc = setsockopt( s, IPPROTO_TCP, TCP_NODELAY,
1353 (char *)&tmp, sizeof(tmp) );
1354 if ( rc == AC_SOCKET_ERROR ) {
1355 int err = sock_errno();
1357 LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
1358 "slapd_daemon_task: setsockopt( %ld, TCP_NODELAY) failed errno=%d (%s)\n",
1359 (long)s, err, sock_errstr(err) ));
1361 Debug( LDAP_DEBUG_ANY,
1362 "slapd(%ld): setsockopt(TCP_NODELAY) failed "
1363 "errno=%d (%s)\n", (long) s, err, sock_errstr(err) );
1371 LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1,
1372 "slapd_daemon_task: new connection on %ld\n", (long)s ));
1374 Debug( LDAP_DEBUG_CONNS, "daemon: new connection on %ld\n",
1377 switch ( from.sa_addr.sa_family ) {
1378 # ifdef LDAP_PF_LOCAL
1380 sprintf( peername, "PATH=%s", from.sa_un_addr.sun_path );
1381 ssf = LDAP_PVT_SASL_LOCAL_SSF;
1384 #endif /* LDAP_PF_LOCAL */
1386 # ifdef LDAP_PF_INET6
1388 if ( IN6_IS_ADDR_V4MAPPED(&from.sa_in6_addr.sin6_addr) ) {
1389 peeraddr = inet_ntoa( *((struct in_addr *)
1390 &from.sa_in6_addr.sin6_addr.s6_addr[12]) );
1391 sprintf( peername, "IP=%s:%d",
1392 peeraddr != NULL ? peeraddr : "unknown",
1393 (unsigned) ntohs( from.sa_in6_addr.sin6_port ) );
1395 char addr[INET6_ADDRSTRLEN];
1396 sprintf( peername, "IP=%s %d",
1397 inet_ntop( AF_INET6,
1398 &from.sa_in6_addr.sin6_addr,
1399 addr, sizeof addr) ? addr : "unknown",
1400 (unsigned) ntohs( from.sa_in6_addr.sin6_port ) );
1403 # endif /* LDAP_PF_INET6 */
1406 peeraddr = inet_ntoa( from.sa_in_addr.sin_addr );
1407 sprintf( peername, "IP=%s:%d",
1408 peeraddr != NULL ? peeraddr : "unknown",
1409 (unsigned) ntohs( from.sa_in_addr.sin_port ) );
1417 if ( ( from.sa_addr.sa_family == AF_INET )
1418 #ifdef LDAP_PF_INET6
1419 || ( from.sa_addr.sa_family == AF_INET6 )
1422 #ifdef SLAPD_RLOOKUPS
1423 if ( use_reverse_lookup ) {
1424 # ifdef LDAP_PF_INET6
1425 if ( from.sa_addr.sa_family == AF_INET6 )
1427 (char *)&(from.sa_in6_addr.sin6_addr),
1428 sizeof(from.sa_in6_addr.sin6_addr),
1431 # endif /* LDAP_PF_INET6 */
1433 (char *) &(from.sa_in_addr.sin_addr),
1434 sizeof(from.sa_in_addr.sin_addr),
1436 dnsname = hp ? ldap_pvt_str2lower( hp->h_name ) : NULL;
1440 #endif /* SLAPD_RLOOKUPS */
1443 if ( !hosts_ctl("slapd",
1444 dnsname != NULL ? dnsname : STRING_UNKNOWN,
1445 peeraddr != NULL ? peeraddr : STRING_UNKNOWN,
1449 Statslog( LDAP_DEBUG_ANY,
1450 "fd=%ld host access from %s (%s) denied.\n",
1452 dnsname != NULL ? dnsname : "unknown",
1453 peeraddr != NULL ? peeraddr : "unknown",
1458 #endif /* HAVE_TCPD */
1461 id = connection_init(s,
1462 slap_listeners[l]->sl_url,
1463 dnsname != NULL ? dnsname : "unknown",
1465 slap_listeners[l]->sl_name,
1467 slap_listeners[l]->sl_is_tls,
1474 if( authid ) ch_free(authid);
1478 LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
1479 "slapd_daemon_task: connection_init(%ld, %s, %s) failed.\n",
1480 (long)s, peername, slap_listeners[l]->sl_name ));
1482 Debug( LDAP_DEBUG_ANY,
1483 "daemon: connection_init(%ld, %s, %s) failed.\n",
1486 slap_listeners[l]->sl_name );
1492 Statslog( LDAP_DEBUG_STATS,
1493 "daemon: conn=%ld fd=%ld connection from %s (%s) accepted.\n",
1496 slap_listeners[l]->sl_name,
1505 LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL2,
1506 "slapd_daemon_task: activity on " ));
1508 Debug( LDAP_DEBUG_CONNS, "daemon: activity on:", 0, 0, 0 );
1511 for ( i = 0; i < readfds.fd_count; i++ ) {
1513 LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL2,
1514 " %d%s", readfds.fd_array[i], "r", 0 ));
1516 Debug( LDAP_DEBUG_CONNS, " %d%s",
1517 readfds.fd_array[i], "r", 0 );
1520 for ( i = 0; i < writefds.fd_count; i++ ) {
1522 LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL2,
1523 " %d%s", writefds.fd_array[i], "w" ));
1525 Debug( LDAP_DEBUG_CONNS, " %d%s",
1526 writefds.fd_array[i], "w", 0 );
1531 for ( i = 0; i < nfds; i++ ) {
1533 int is_listener = 0;
1535 for ( l = 0; slap_listeners[l] != NULL; l++ ) {
1536 if ( i == slap_listeners[l]->sl_sd ) {
1537 #ifdef LDAP_CONNECTIONLESS
1538 /* The listener is the data port. Don't
1541 if (slap_listeners[l]->sl_is_udp)
1548 if ( is_listener ) {
1551 r = FD_ISSET( i, &readfds );
1552 w = FD_ISSET( i, &writefds );
1555 LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL2,
1557 r ? "r" : "", w ? "w" : "" ));
1559 Debug( LDAP_DEBUG_CONNS, " %d%s%s", i,
1560 r ? "r" : "", w ? "w" : "" );
1566 LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL2, "\n" ));
1568 Debug( LDAP_DEBUG_CONNS, "\n", 0, 0, 0 );
1573 /* loop through the writers */
1575 for ( i = 0; i < writefds.fd_count; i++ )
1577 for ( i = 0; i < nfds; i++ )
1581 int is_listener = 0;
1583 wd = writefds.fd_array[i];
1585 if( ! FD_ISSET( i, &writefds ) ) {
1591 for ( l = 0; slap_listeners[l] != NULL; l++ ) {
1592 if ( i == slap_listeners[l]->sl_sd ) {
1593 #ifdef LDAP_CONNECTIONLESS
1594 if (slap_listeners[l]->sl_is_udp)
1601 if ( is_listener ) {
1605 LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL2,
1606 "slapd_daemon_task: write active on %d\n", wd ));
1608 Debug( LDAP_DEBUG_CONNS,
1609 "daemon: write active on %d\n",
1613 * NOTE: it is possible that the connection was closed
1614 * and that the stream is now inactive.
1615 * connection_write() must valid the stream is still
1619 if ( connection_write( wd ) < 0 ) {
1620 FD_CLR( (unsigned) wd, &readfds );
1626 for ( i = 0; i < readfds.fd_count; i++ )
1628 for ( i = 0; i < nfds; i++ )
1632 int is_listener = 0;
1635 rd = readfds.fd_array[i];
1637 if( ! FD_ISSET( i, &readfds ) ) {
1643 for ( l = 0; slap_listeners[l] != NULL; l++ ) {
1644 if ( rd == slap_listeners[l]->sl_sd ) {
1645 #ifdef LDAP_CONNECTIONLESS
1646 if (slap_listeners[l]->sl_is_udp)
1653 if ( is_listener ) {
1658 LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL2,
1659 "slapd_daemon_task: read activity on %d\n", rd ));
1661 Debug ( LDAP_DEBUG_CONNS,
1662 "daemon: read activity on %d\n", rd, 0, 0 );
1665 * NOTE: it is possible that the connection was closed
1666 * and that the stream is now inactive.
1667 * connection_read() must valid the stream is still
1671 if ( connection_read( rd ) < 0 ) {
1675 ldap_pvt_thread_yield();
1678 if( slapd_shutdown == 1 ) {
1680 LDAP_LOG(( "connection", LDAP_LEVEL_CRIT,
1681 "slapd_daemon_task: shutdown requested and initiated.\n"));
1683 Debug( LDAP_DEBUG_TRACE,
1684 "daemon: shutdown requested and initiated.\n",
1688 } else if ( slapd_shutdown == 2 ) {
1689 #ifdef HAVE_NT_SERVICE_MANAGER
1691 LDAP_LOG(( "connection", LDAP_LEVEL_CRIT,
1692 "slapd_daemon_task: shutdown initiated by Service Manager.\n"));
1694 Debug( LDAP_DEBUG_TRACE,
1695 "daemon: shutdown initiated by Service Manager.\n",
1698 #else /* !HAVE_NT_SERVICE_MANAGER */
1700 LDAP_LOG(( "connection", LDAP_LEVEL_CRIT,
1701 "slapd_daemon_task: abnormal condition, shutdown initiated.\n" ));
1703 Debug( LDAP_DEBUG_TRACE,
1704 "daemon: abnormal condition, shutdown initiated.\n",
1707 #endif /* !HAVE_NT_SERVICE_MANAGER */
1710 LDAP_LOG(( "connection", LDAP_LEVEL_CRIT,
1711 "slapd_daemon_task: no active streams, shutdown initiated.\n" ));
1713 Debug( LDAP_DEBUG_TRACE,
1714 "daemon: no active streams, shutdown initiated.\n",
1719 for ( l = 0; slap_listeners[l] != NULL; l++ ) {
1720 if ( slap_listeners[l]->sl_sd != AC_SOCKET_INVALID ) {
1721 #ifdef LDAP_PF_LOCAL
1722 if ( slap_listeners[l]->sl_sa.sa_addr.sa_family == AF_LOCAL ) {
1723 unlink( slap_listeners[l]->sl_sa.sa_un_addr.sun_path );
1725 #endif /* LDAP_PF_LOCAL */
1726 slapd_close( slap_listeners[l]->sl_sd );
1728 if ( slap_listeners[l]->sl_url )
1729 free ( slap_listeners[l]->sl_url );
1730 if ( slap_listeners[l]->sl_name )
1731 free ( slap_listeners[l]->sl_name );
1732 free ( slap_listeners[l] );
1734 free ( slap_listeners );
1735 slap_listeners = NULL;
1738 LDAP_LOG(( "connection", LDAP_LEVEL_CRIT,
1739 "slapd_daemon_task: shutdown waiting for %d threads to terminate.\n",
1740 ldap_pvt_thread_pool_backload(&connection_pool) ));
1742 Debug( LDAP_DEBUG_ANY,
1743 "slapd shutdown: waiting for %d threads to terminate\n",
1744 ldap_pvt_thread_pool_backload(&connection_pool), 0, 0 );
1746 ldap_pvt_thread_pool_destroy(&connection_pool, 1);
1752 int slapd_daemon( void )
1758 #define SLAPD_LISTENER_THREAD 1
1759 #if defined( SLAPD_LISTENER_THREAD )
1761 ldap_pvt_thread_t listener_tid;
1763 /* listener as a separate THREAD */
1764 rc = ldap_pvt_thread_create( &listener_tid,
1765 0, slapd_daemon_task, NULL );
1769 LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
1770 "slapd_daemon: listener ldap_pvt_thread_create failed (%d).\n", rc ));
1772 Debug( LDAP_DEBUG_ANY,
1773 "listener ldap_pvt_thread_create failed (%d)\n", rc, 0, 0 );
1778 /* wait for the listener thread to complete */
1779 ldap_pvt_thread_join( listener_tid, (void *) NULL );
1782 /* experimental code */
1783 slapd_daemon_task( NULL );
1792 #if defined( HAVE_WINSOCK2 )
1793 WORD wVersionRequested;
1797 wVersionRequested = MAKEWORD( 2, 0 );
1799 err = WSAStartup( wVersionRequested, &wsaData );
1801 /* Tell the user that we couldn't find a usable */
1806 /* Confirm that the WinSock DLL supports 2.0.*/
1807 /* Note that if the DLL supports versions greater */
1808 /* than 2.0 in addition to 2.0, it will still return */
1809 /* 2.0 in wVersion since that is the version we */
1812 if ( LOBYTE( wsaData.wVersion ) != 2 ||
1813 HIBYTE( wsaData.wVersion ) != 0 )
1815 /* Tell the user that we couldn't find a usable */
1821 /* The WinSock DLL is acceptable. Proceed. */
1822 #elif defined( HAVE_WINSOCK )
1824 if ( WSAStartup( 0x0101, &wsaData ) != 0 ) {
1831 int sockdestroy(void)
1833 #if defined( HAVE_WINSOCK2 ) || defined( HAVE_WINSOCK )
1840 slap_sig_shutdown( int sig )
1843 LDAP_LOG(( "connection", LDAP_LEVEL_CRIT,
1844 "slap_sig_shutdown: signal %d\n", sig ));
1846 Debug(LDAP_DEBUG_TRACE, "slap_sig_shutdown: signal %d\n", sig, 0, 0);
1850 * If the NT Service Manager is controlling the server, we don't
1851 * want SIGBREAK to kill the server. For some strange reason,
1852 * SIGBREAK is generated when a user logs out.
1855 #if HAVE_NT_SERVICE_MANAGER && SIGBREAK
1856 if (is_NT_Service && sig == SIGBREAK)
1858 LDAP_LOG(( "connection", LDAP_LEVEL_CRIT,
1859 "slap_sig_shutdown: SIGBREAK ignored.\n" ));
1861 Debug(LDAP_DEBUG_TRACE, "slap_sig_shutdown: SIGBREAK ignored.\n",
1870 /* reinstall self */
1871 (void) SIGNAL_REINSTALL( sig, slap_sig_shutdown );
1875 slap_sig_wake( int sig )
1879 /* reinstall self */
1880 (void) SIGNAL_REINSTALL( sig, slap_sig_wake );
1884 void slapd_add_internal(ber_socket_t s) {
1888 Listener ** slapd_get_listeners(void) {
1889 return slap_listeners;