3 * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
13 #include <ac/signal.h>
14 #include <ac/socket.h>
15 #include <ac/string.h>
17 #include <ac/unistd.h>
20 #include "ldap_pvt_thread.h"
27 int allow_severity = LOG_INFO;
28 int deny_severity = LOG_NOTICE;
29 #endif /* TCP Wrappers */
33 /* this should go in <ldap.h> as soon as it is accepted */
34 #define LDAPI_MOD_URLEXT "x-mod"
35 #endif /* LDAP_PF_LOCAL */
39 ber_socket_t dtblsize;
41 Listener **slap_listeners = NULL;
43 #define SLAPD_LISTEN 10
45 static ber_socket_t wake_sds[2];
49 #define WAKE_LISTENER(w) \
50 ((w && !waking) ? tcp_write( wake_sds[1], "0", 1 ), waking=1 : 0)
52 #define WAKE_LISTENER(w) \
53 do { if (w) tcp_write( wake_sds[1], "0", 1 ); } while(0)
59 volatile sig_atomic_t slapd_shutdown = 0;
61 static struct slap_daemon {
62 ldap_pvt_thread_mutex_t sd_mutex;
67 /* In winsock, accept() returns values higher than dtblsize
68 so don't bother with this optimization */
81 * SLP related functions
85 #define LDAP_SRVTYPE_PREFIX "service:ldap://"
86 #define LDAPS_SRVTYPE_PREFIX "service:ldaps://"
87 static char** slapd_srvurls = NULL;
88 static SLPHandle slapd_hslp = 0;
90 void slapd_slp_init( const char* urls ) {
93 slapd_srvurls = str2charray( urls, " " );
95 if( slapd_srvurls == NULL ) return;
97 /* find and expand INADDR_ANY URLs */
98 for( i=0; slapd_srvurls[i] != NULL; i++ ) {
99 if( strcmp( slapd_srvurls[i], "ldap:///" ) == 0) {
100 char *host = ldap_pvt_get_fqdn( NULL );
101 if ( host != NULL ) {
102 slapd_srvurls[i] = (char *) realloc( slapd_srvurls[i],
104 sizeof( LDAP_SRVTYPE_PREFIX ) );
105 strcpy( slap_strcopy(slapd_srvurls[i],
106 LDAP_SRVTYPE_PREFIX ), host );
111 } else if ( strcmp( slapd_srvurls[i], "ldaps:///" ) == 0) {
112 char *host = ldap_pvt_get_fqdn( NULL );
113 if ( host != NULL ) {
114 slapd_srvurls[i] = (char *) realloc( slapd_srvurls[i],
116 sizeof( LDAPS_SRVTYPE_PREFIX ) );
117 strcpy( slap_strcopy(slapd_srvurls[i],
118 LDAPS_SRVTYPE_PREFIX ), host );
125 /* open the SLP handle */
126 SLPOpen( "en", 0, &slapd_hslp );
129 void slapd_slp_deinit() {
130 if( slapd_srvurls == NULL ) return;
132 charray_free( slapd_srvurls );
133 slapd_srvurls = NULL;
135 /* close the SLP handle */
136 SLPClose( slapd_hslp );
139 void slapd_slp_regreport(
147 void slapd_slp_reg() {
150 for( i=0; slapd_srvurls[i] != NULL; i++ ) {
151 if( strncmp( slapd_srvurls[i], LDAP_SRVTYPE_PREFIX,
152 sizeof( LDAP_SRVTYPE_PREFIX ) - 1 ) == 0 ||
153 strncmp( slapd_srvurls[i], LDAPS_SRVTYPE_PREFIX,
154 sizeof( LDAPS_SRVTYPE_PREFIX ) - 1 ) == 0 )
158 SLP_LIFETIME_MAXIMUM,
168 void slapd_slp_dereg() {
171 for( i=0; slapd_srvurls[i] != NULL; i++ ) {
172 SLPDereg( slapd_hslp,
178 #endif /* HAVE_SLP */
181 * Add a descriptor to daemon control
183 static void slapd_add(ber_socket_t s) {
184 ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
186 assert( !FD_ISSET( s, &slap_daemon.sd_actives ));
187 assert( !FD_ISSET( s, &slap_daemon.sd_readers ));
188 assert( !FD_ISSET( s, &slap_daemon.sd_writers ));
191 if (s >= slap_daemon.sd_nfds) {
192 slap_daemon.sd_nfds = s + 1;
196 FD_SET( s, &slap_daemon.sd_actives );
197 FD_SET( s, &slap_daemon.sd_readers );
200 LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1,
201 "slapd_add: added %ld%s%s\n",
203 FD_ISSET(s, &slap_daemon.sd_readers) ? "r" : "",
204 FD_ISSET(s, &slap_daemon.sd_writers) ? "w" : "" ));
206 Debug( LDAP_DEBUG_CONNS, "daemon: added %ld%s%s\n",
208 FD_ISSET(s, &slap_daemon.sd_readers) ? "r" : "",
209 FD_ISSET(s, &slap_daemon.sd_writers) ? "w" : "" );
211 ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
215 * Remove the descriptor from daemon control
217 void slapd_remove(ber_socket_t s, int wake) {
218 ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
221 LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1,
222 "slapd_remove: removing %ld%s%s\n",
224 FD_ISSET(s, &slap_daemon.sd_readers) ? "r" : "",
225 FD_ISSET(s, &slap_daemon.sd_writers) ? "w" : "" ));
227 Debug( LDAP_DEBUG_CONNS, "daemon: removing %ld%s%s\n",
229 FD_ISSET(s, &slap_daemon.sd_readers) ? "r" : "",
230 FD_ISSET(s, &slap_daemon.sd_writers) ? "w" : "" );
232 FD_CLR( s, &slap_daemon.sd_actives );
233 FD_CLR( s, &slap_daemon.sd_readers );
234 FD_CLR( s, &slap_daemon.sd_writers );
236 ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
240 void slapd_clr_write(ber_socket_t s, int wake) {
241 ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
243 assert( FD_ISSET( s, &slap_daemon.sd_actives) );
244 FD_CLR( s, &slap_daemon.sd_writers );
246 ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
250 void slapd_set_write(ber_socket_t s, int wake) {
251 ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
253 assert( FD_ISSET( s, &slap_daemon.sd_actives) );
254 if (!FD_ISSET(s, &slap_daemon.sd_writers))
255 FD_SET( (unsigned) s, &slap_daemon.sd_writers );
257 ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
261 void slapd_clr_read(ber_socket_t s, int wake) {
262 ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
264 assert( FD_ISSET( s, &slap_daemon.sd_actives) );
265 FD_CLR( s, &slap_daemon.sd_readers );
267 ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
271 void slapd_set_read(ber_socket_t s, int wake) {
272 ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
274 assert( FD_ISSET( s, &slap_daemon.sd_actives) );
275 if (!FD_ISSET(s, &slap_daemon.sd_readers))
276 FD_SET( s, &slap_daemon.sd_readers );
278 ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
282 static void slapd_close(ber_socket_t s) {
284 LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1,
285 "slapd_close: closing %ld\n", (long)s ));
287 Debug( LDAP_DEBUG_CONNS, "daemon: closing %ld\n",
293 static void slap_free_listener_addresses(struct sockaddr **sal)
295 struct sockaddr **sap;
301 for (sap = sal; *sap != NULL; sap++) {
309 static int get_url_perms(
321 for ( i = 0; exts[ i ]; i++ ) {
322 char *type = exts[ i ];
325 if ( type[ 0 ] == '!' ) {
330 if ( strncasecmp( type, LDAPI_MOD_URLEXT "=", sizeof(LDAPI_MOD_URLEXT "=") - 1 ) == 0 ) {
331 char *value = type + sizeof(LDAPI_MOD_URLEXT "=") - 1;
335 if ( strlen(value) != 3 ) {
339 for ( j = 0; j < 3; j++ ) {
341 = { S_IRWXU, S_IRWXG, S_IRWXO };
343 switch ( value[ j ] ) {
363 #endif /* LDAP_PF_LOCAL */
365 /* port = 0 indicates AF_LOCAL */
366 static int slap_get_listener_addresses(
369 struct sockaddr ***sal)
371 struct sockaddr **sap;
375 *sal = ch_malloc(2 * sizeof(void *));
381 *sap = ch_malloc(sizeof(struct sockaddr_un));
387 (sizeof(((struct sockaddr_un *)*sap)->sun_path) - 1) ) {
389 LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
390 "slap_get_listener_addresses: domain socket path (%s) too long in URL\n",
393 Debug( LDAP_DEBUG_ANY,
394 "daemon: domain socket path (%s) too long in URL",
400 (void)memset( (void *)*sap, '\0', sizeof(struct sockaddr_un) );
401 (*sap)->sa_family = AF_LOCAL;
402 strcpy( ((struct sockaddr_un *)*sap)->sun_path, host );
406 #ifdef HAVE_GETADDRINFO
407 struct addrinfo hints, *res, *sai;
411 memset( &hints, '\0', sizeof(hints) );
412 hints.ai_flags = AI_PASSIVE;
413 hints.ai_socktype = SOCK_STREAM;
414 hints.ai_family = AF_UNSPEC;
415 snprintf(serv, sizeof serv, "%d", port);
417 if ( (err = getaddrinfo(host, serv, &hints, &res)) ) {
419 LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
420 "slap_get_listener_addresses: getaddrinfo failed: %s\n",
421 AC_GAI_STRERROR(err) ));
423 Debug( LDAP_DEBUG_ANY, "daemon: getaddrinfo failed: %s\n",
424 AC_GAI_STRERROR(err), 0, 0);
430 for (n=2; (sai = sai->ai_next) != NULL; n++) {
433 *sal = ch_calloc(n, sizeof(void *));
441 for ( sai=res; sai; sai=sai->ai_next ) {
442 if( sai->ai_addr == NULL ) {
444 LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
445 "slap_get_listener_addresses: "
446 "getaddrinfo ai_addr is NULL?\n" ));
448 Debug( LDAP_DEBUG_ANY, "slap_get_listener_addresses: "
449 "getaddrinfo ai_addr is NULL?\n", 0, 0, 0 );
455 switch (sai->ai_family) {
456 # ifdef LDAP_PF_INET6
458 *sap = ch_malloc(sizeof(struct sockaddr_in6));
463 *(struct sockaddr_in6 *)*sap =
464 *((struct sockaddr_in6 *)sai->ai_addr);
468 *sap = ch_malloc(sizeof(struct sockaddr_in));
473 *(struct sockaddr_in *)*sap =
474 *((struct sockaddr_in *)sai->ai_addr);
482 (*sap)->sa_family = sai->ai_family;
492 if ( host == NULL ) {
493 in.s_addr = htonl(INADDR_ANY);
495 } else if ( !inet_aton( host, &in ) ) {
496 struct hostent *he = gethostbyname( host );
499 LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
500 "slap_get_listener_addresses: invalid host %s\n",
503 Debug( LDAP_DEBUG_ANY,
504 "daemon: invalid host %s", host, 0, 0);
508 AC_MEMCPY( &in, he->h_addr, sizeof( in ) );
511 *sal = ch_malloc(2 * sizeof(void *));
517 *sap = ch_malloc(sizeof(struct sockaddr_in));
523 (void)memset( (void *)*sap, '\0', sizeof(struct sockaddr_in) );
524 (*sap)->sa_family = AF_INET;
525 ((struct sockaddr_in *)*sap)->sin_port = htons(port);
526 ((struct sockaddr_in *)*sap)->sin_addr = in;
533 slap_free_listener_addresses(*sal);
537 static Listener * slap_open_listener(
545 int err, addrlen = 0;
546 struct sockaddr **sal, **psal;
547 int socktype = SOCK_STREAM; /* default to COTS */
549 mode_t perms = S_IRWXU;
553 rc = ldap_url_parse( url, &lud );
555 if( rc != LDAP_URL_SUCCESS ) {
557 LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
558 "slap_open_listener: listen URL \"%s\" parse error %d\n",
561 Debug( LDAP_DEBUG_ANY,
562 "daemon: listen URL \"%s\" parse error=%d\n",
569 if( ldap_pvt_url_scheme2tls( lud->lud_scheme ) ) {
571 LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
572 "slap_open_listener: TLS is not supported (%s)\n",
575 Debug( LDAP_DEBUG_ANY,
576 "daemon: TLS not supported (%s)\n",
579 ldap_free_urldesc( lud );
583 if(! lud->lud_port ) {
584 lud->lud_port = LDAP_PORT;
588 l.sl_is_tls = ldap_pvt_url_scheme2tls( lud->lud_scheme );
590 if(! lud->lud_port ) {
591 lud->lud_port = l.sl_is_tls ? LDAPS_PORT : LDAP_PORT;
595 port = (unsigned short) lud->lud_port;
597 tmp = ldap_pvt_url_scheme2proto(lud->lud_scheme);
598 if ( tmp == LDAP_PROTO_IPC ) {
600 if ( lud->lud_host == NULL || lud->lud_host[0] == '\0' ) {
601 err = slap_get_listener_addresses(LDAPI_SOCK, 0, &sal);
603 err = slap_get_listener_addresses(lud->lud_host, 0, &sal);
606 if ( lud->lud_exts ) {
607 err = get_url_perms( lud->lud_exts, &perms, &crit );
612 LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
613 "slap_open_listener: URL scheme is not supported: %s\n",
616 Debug( LDAP_DEBUG_ANY, "daemon: URL scheme not supported: %s",
619 ldap_free_urldesc( lud );
623 #ifdef LDAP_CONNECTIONLESS
624 l.sl_is_udp = ( tmp == LDAP_PROTO_UDP );
626 if( lud->lud_host == NULL || lud->lud_host[0] == '\0'
627 || strcmp(lud->lud_host, "*") == 0 )
629 err = slap_get_listener_addresses(NULL, port, &sal);
631 err = slap_get_listener_addresses(lud->lud_host, port, &sal);
635 ldap_free_urldesc( lud );
641 while ( *sal != NULL ) {
642 switch( (*sal)->sa_family ) {
655 #ifdef LDAP_CONNECTIONLESS
657 socktype = SOCK_DGRAM;
659 l.sl_sd = socket( (*sal)->sa_family, socktype, 0);
660 if ( l.sl_sd == AC_SOCKET_INVALID ) {
661 int err = sock_errno();
663 LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
664 "slap_open_listener: socket() failed errno=%d (%s)\n",
665 err, sock_errstr(err) ));
667 Debug( LDAP_DEBUG_ANY,
668 "daemon: socket() failed errno=%d (%s)\n", err,
669 sock_errstr(err), 0 );
675 if ( l.sl_sd >= dtblsize ) {
677 LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
678 "slap_open_listener: listener descriptor %ld is too great %ld\n",
679 (long)l.sl_sd, (long)dtblsize ));
681 Debug( LDAP_DEBUG_ANY,
682 "daemon: listener descriptor %ld is too great %ld\n",
683 (long) l.sl_sd, (long) dtblsize, 0 );
685 tcp_close( l.sl_sd );
691 if ( (*sal)->sa_family == AF_LOCAL ) {
692 unlink ( ((struct sockaddr_un *)*sal)->sun_path );
697 /* enable address reuse */
699 rc = setsockopt( l.sl_sd, SOL_SOCKET, SO_REUSEADDR,
700 (char *) &tmp, sizeof(tmp) );
701 if ( rc == AC_SOCKET_ERROR ) {
702 int err = sock_errno();
704 LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
705 "slap_open_listener: setsockopt( %ld, SO_REUSEADDR ) failed errno %d (%s)\n",
706 (long)l.sl_sd, err, sock_errstr(err) ));
708 Debug( LDAP_DEBUG_ANY,
709 "slapd(%ld): setsockopt(SO_REUSEADDR) failed errno=%d (%s)\n",
710 (long) l.sl_sd, err, sock_errstr(err) );
716 switch( (*sal)->sa_family ) {
718 addrlen = sizeof(struct sockaddr_in);
722 addrlen = sizeof(struct sockaddr_in6);
727 addrlen = sizeof(struct sockaddr_un);
732 if (!bind(l.sl_sd, *sal, addrlen))
736 LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
737 "slap_open_listener: bind(%ld) failed errno=%d (%s)\n",
738 (long)l.sl_sd, err, sock_errstr(err) ));
740 Debug( LDAP_DEBUG_ANY, "daemon: bind(%ld) failed errno=%d (%s)\n",
741 (long) l.sl_sd, err, sock_errstr(err) );
743 tcp_close( l.sl_sd );
745 } /* while ( *sal != NULL ) */
747 if ( *sal == NULL ) {
749 LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
750 "slap_open_listener: bind(%ld) failed.\n", (long)l.sl_sd ));
752 Debug( LDAP_DEBUG_ANY, "daemon: bind(%ld) failed\n",
753 (long) l.sl_sd, 0, 0 );
755 slap_free_listener_addresses(psal);
759 switch ( (*sal)->sa_family ) {
762 char *addr = ((struct sockaddr_un *)*sal)->sun_path;
763 if ( chmod( addr, perms ) < 0 && crit ) {
764 int err = sock_errno();
766 LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
767 "slap_open_listener: fchmod(%ld) failed errno=%d (%s)\n",
768 (long)l.sl_sd, err, sock_errstr(err) ));
770 Debug( LDAP_DEBUG_ANY, "daemon: fchmod(%ld) failed errno=%d (%s)",
771 (long) l.sl_sd, err, sock_errstr(err) );
773 tcp_close( l.sl_sd );
774 slap_free_listener_addresses(psal);
777 l.sl_name = ch_malloc( strlen(addr) + sizeof("PATH=") );
778 sprintf( l.sl_name, "PATH=%s", addr );
780 #endif /* LDAP_PF_LOCAL */
784 #if defined( HAVE_GETADDRINFO ) && defined( HAVE_INET_NTOP )
785 char addr[INET_ADDRSTRLEN];
786 inet_ntop( AF_INET, &((struct sockaddr_in *)*sal)->sin_addr,
787 addr, sizeof(addr) );
790 s = inet_ntoa( ((struct sockaddr_in *) *sal)->sin_addr );
792 port = ntohs( ((struct sockaddr_in *)*sal) ->sin_port );
793 l.sl_name = ch_malloc( sizeof("IP=255.255.255.255:65535") );
794 sprintf( l.sl_name, "IP=%s:%d",
795 s != NULL ? s : "unknown" , port );
800 char addr[INET6_ADDRSTRLEN];
801 inet_ntop( AF_INET6, &((struct sockaddr_in6 *)*sal)->sin6_addr,
803 port = ntohs( ((struct sockaddr_in6 *)*sal)->sin6_port );
804 l.sl_name = ch_malloc( strlen(addr) + sizeof("IP= 65535") );
805 sprintf( l.sl_name, "IP=%s %d", addr, port );
807 #endif /* LDAP_PF_INET6 */
811 LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
812 "slap_open_listener: unsupported address family (%d)\n",
813 (int)(*sal)->sa_family ));
815 Debug( LDAP_DEBUG_ANY, "daemon: unsupported address family (%d)\n",
816 (int) (*sal)->sa_family, 0, 0 );
821 slap_free_listener_addresses(psal);
823 l.sl_url = ch_strdup( url );
824 li = ch_malloc( sizeof( Listener ) );
828 LDAP_LOG(( "connection", LDAP_LEVEL_RESULTS,
829 "slap_open_listener: daemon initialzed %s\n", l.sl_url ));
831 Debug( LDAP_DEBUG_TRACE, "daemon: initialized %s\n",
837 static int sockinit(void);
838 static int sockdestroy(void);
840 int slapd_daemon_init( const char *urls )
846 LDAP_LOG(( "connection", LDAP_LEVEL_ARGS,
847 "slapd_daemon_init: %s\n",
848 urls ? urls : "<null>" ));
850 Debug( LDAP_DEBUG_ARGS, "daemon_init: %s\n",
851 urls ? urls : "<null>", 0, 0 );
853 if( (rc = sockinit()) != 0 ) {
858 dtblsize = sysconf( _SC_OPEN_MAX );
859 #elif HAVE_GETDTABLESIZE
860 dtblsize = getdtablesize();
862 dtblsize = FD_SETSIZE;
866 if(dtblsize > FD_SETSIZE) {
867 dtblsize = FD_SETSIZE;
869 #endif /* !FD_SETSIZE */
871 /* open a pipe (or something equivalent connected to itself).
872 * we write a byte on this fd whenever we catch a signal. The main
873 * loop will be select'ing on this socket, and will wake up when
876 if( (rc = lutil_pair( wake_sds )) < 0 ) {
878 LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
879 "slap_daemon_init: lutil_pair() failed rc=%d\n", rc ));
881 Debug( LDAP_DEBUG_ANY,
882 "daemon: lutil_pair() failed rc=%d\n", rc, 0, 0 );
887 FD_ZERO( &slap_daemon.sd_readers );
888 FD_ZERO( &slap_daemon.sd_writers );
894 u = str2charray( urls, " " );
896 if( u == NULL || u[0] == NULL ) {
898 LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
899 "slap_daemon_init: no urls (%s) provided.\n", urls ));
901 Debug( LDAP_DEBUG_ANY, "daemon_init: no urls (%s) provided.\n",
907 for( i=0; u[i] != NULL; i++ ) {
909 LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1,
910 "slap_daemon_init: listen on %s\n.", u[i] ));
912 Debug( LDAP_DEBUG_TRACE, "daemon_init: listen on %s\n",
919 LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
920 "slap_daemon_init: no listeners to open (%s)\n", urls ));
922 Debug( LDAP_DEBUG_ANY, "daemon_init: no listeners to open (%s)\n",
930 LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
931 "slap_daemon_init: %d listeners to open...\n", i ));
933 Debug( LDAP_DEBUG_TRACE, "daemon_init: %d listeners to open...\n",
936 slap_listeners = ch_malloc( (i+1)*sizeof(Listener *) );
938 for(i = 0; u[i] != NULL; i++ ) {
939 slap_listeners[i] = slap_open_listener( u[i] );
941 if( slap_listeners[i] == NULL ) {
946 slap_listeners[i] = NULL;
949 LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1,
950 "slap_daemon_init: %d listeners opened\n", i ));
952 Debug( LDAP_DEBUG_TRACE, "daemon_init: %d listeners opened\n",
957 slapd_slp_init( urls );
962 ldap_pvt_thread_mutex_init( &slap_daemon.sd_mutex );
968 slapd_daemon_destroy(void)
970 connections_destroy();
971 tcp_close( wake_sds[1] );
972 tcp_close( wake_sds[0] );
990 time_t last_idle_check = 0;
993 if ( global_idletimeout > 0 ) {
994 last_idle_check = slap_get_time();
996 for ( l = 0; slap_listeners[l] != NULL; l++ ) {
997 if ( slap_listeners[l]->sl_sd == AC_SOCKET_INVALID )
999 #ifdef LDAP_CONNECTIONLESS
1000 /* Since this is connectionless, the data port is the
1001 * listening port. The listen() and accept() calls
1004 if ( slap_listeners[l]->sl_is_udp )
1006 slapd_add( slap_listeners[l]->sl_sd );
1011 if ( listen( slap_listeners[l]->sl_sd, SLAPD_LISTEN ) == -1 ) {
1012 int err = sock_errno();
1014 LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
1015 "slapd_daemon_task: listen( %s, 5 ) failed errno=%d (%s)\n",
1016 slap_listeners[l]->sl_url, err, sock_errstr(err) ));
1018 Debug( LDAP_DEBUG_ANY,
1019 "daemon: listen(%s, 5) failed errno=%d (%s)\n",
1020 slap_listeners[l]->sl_url, err,
1023 return( (void*)-1 );
1026 slapd_add( slap_listeners[l]->sl_sd );
1029 #ifdef HAVE_NT_SERVICE_MANAGER
1030 if ( started_event != NULL ) {
1031 ldap_pvt_thread_cond_signal( &started_event );
1034 /* initialization complete. Here comes the loop. */
1036 while ( !slapd_shutdown ) {
1041 #define SLAPD_EBADF_LIMIT 16
1045 #define SLAPD_IDLE_CHECK_LIMIT 4
1053 #if defined(SLAPD_RLOOKUPS)
1056 struct timeval zero;
1057 struct timeval *tvp;
1060 now = slap_get_time();
1061 connections_timeout_idle( now );
1063 else if ( global_idletimeout > 0 ) {
1064 now = slap_get_time();
1065 if ( difftime( last_idle_check+global_idletimeout/SLAPD_IDLE_CHECK_LIMIT, now ) < 0 ) {
1066 connections_timeout_idle( now );
1070 FD_ZERO( &writefds );
1071 FD_ZERO( &readfds );
1076 ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
1078 #ifdef FD_SET_MANUAL_COPY
1079 for( s = 0; s < nfds; s++ ) {
1080 if(FD_ISSET( &slap_sd_readers, s )) {
1081 FD_SET( s, &readfds );
1083 if(FD_ISSET( &slap_sd_writers, s )) {
1084 FD_SET( s, &writefds );
1088 AC_MEMCPY( &readfds, &slap_daemon.sd_readers, sizeof(fd_set) );
1089 AC_MEMCPY( &writefds, &slap_daemon.sd_writers, sizeof(fd_set) );
1091 assert(!FD_ISSET(wake_sds[0], &readfds));
1092 FD_SET( wake_sds[0], &readfds );
1094 for ( l = 0; slap_listeners[l] != NULL; l++ ) {
1095 if ( slap_listeners[l]->sl_sd == AC_SOCKET_INVALID )
1097 if (!FD_ISSET(slap_listeners[l]->sl_sd, &readfds))
1098 FD_SET( slap_listeners[l]->sl_sd, &readfds );
1101 #ifndef HAVE_WINSOCK
1102 nfds = slap_daemon.sd_nfds;
1107 ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
1109 at = ldap_pvt_thread_pool_backload(&connection_pool);
1111 #if defined( HAVE_YIELDING_SELECT ) || defined( NO_THREADS )
1114 tvp = at ? &zero : NULL;
1117 for ( l = 0; slap_listeners[l] != NULL; l++ ) {
1118 if ( slap_listeners[l]->sl_sd == AC_SOCKET_INVALID )
1122 LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1,
1123 "slapd_daemon_task: select: listen=%d active_threads=%d tvp=%s\n",
1124 slap_listeners[l]->sl_sd, at, tvp == NULL ? "NULL" : "zero" ));
1126 Debug( LDAP_DEBUG_CONNS,
1127 "daemon: select: listen=%d active_threads=%d tvp=%s\n",
1128 slap_listeners[l]->sl_sd, at,
1129 tvp == NULL ? "NULL" : "zero" );
1133 switch(ns = select( nfds, &readfds,
1135 /* don't pass empty fd_set */
1136 ( writefds.fd_count > 0 ? &writefds : NULL ),
1142 case -1: { /* failure - try again */
1143 int err = sock_errno();
1147 /* you'd think this would be EBADF */
1148 || err == WSAENOTSOCK
1151 if (++ebadf < SLAPD_EBADF_LIMIT)
1155 if( err != EINTR ) {
1157 LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
1158 "slapd_daemon_task: select failed (%d): %s\n",
1159 err, sock_errstr(err) ));
1161 Debug( LDAP_DEBUG_CONNS,
1162 "daemon: select failed (%d): %s\n",
1163 err, sock_errstr(err), 0 );
1165 slapd_shutdown = -1;
1170 case 0: /* timeout - let threads run */
1173 LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL2,
1174 "slapd_daemon_task: select timeout - yielding\n" ));
1176 Debug( LDAP_DEBUG_CONNS, "daemon: select timeout - yielding\n",
1179 ldap_pvt_thread_yield();
1182 default: /* something happened - deal with it */
1183 if( slapd_shutdown ) continue;
1187 LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL2,
1188 "slapd_daemon_task: activity on %d descriptors\n", ns ));
1190 Debug( LDAP_DEBUG_CONNS, "daemon: activity on %d descriptors\n",
1196 if( FD_ISSET( wake_sds[0], &readfds ) ) {
1198 tcp_read( wake_sds[0], c, sizeof(c) );
1205 for ( l = 0; slap_listeners[l] != NULL; l++ ) {
1207 socklen_t len = sizeof(from);
1210 char *authid = NULL;
1212 char *dnsname = NULL;
1214 #ifdef LDAP_PF_LOCAL
1215 char peername[MAXPATHLEN + sizeof("PATH=")];
1216 #elif defined(LDAP_PF_INET6)
1217 char peername[sizeof("IP=ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff 65535")];
1219 char peername[sizeof("IP=255.255.255.255:65336")];
1220 #endif /* LDAP_PF_LOCAL */
1224 if ( slap_listeners[l]->sl_sd == AC_SOCKET_INVALID )
1227 if ( !FD_ISSET( slap_listeners[l]->sl_sd, &readfds ) )
1230 #ifdef LDAP_CONNECTIONLESS
1231 if ( slap_listeners[l]->sl_is_udp )
1233 /* The first time we receive a query, we set this
1234 * up as a "connection". It remains open for the life
1237 if ( slap_listeners[l]->sl_is_udp < 2 )
1239 id = connection_init(
1240 slap_listeners[l]->sl_sd,
1241 slap_listeners[l]->sl_url, "", "",
1242 slap_listeners[l]->sl_name,
1244 slap_listeners[l]->sl_is_udp++;
1250 s = accept( slap_listeners[l]->sl_sd,
1251 (struct sockaddr *) &from, &len );
1252 if ( s == AC_SOCKET_INVALID ) {
1253 int err = sock_errno();
1256 if( err == EMFILE ) {
1261 if( err == ENFILE ) {
1271 LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
1272 "slapd_daemon_task: accept(%ld) failed errno=%d (%s)\n",
1273 (long)slap_listeners[l]->sl_sd, err, sock_errstr(err) ));
1275 Debug( LDAP_DEBUG_ANY,
1276 "daemon: accept(%ld) failed errno=%d (%s)\n",
1277 (long) slap_listeners[l]->sl_sd, err,
1281 /* prevent busy loop */
1283 if( emfile % 4 == 3 ) usleep( 250 );
1285 if( emfile % 8 == 7 ) sleep( 1 );
1289 ldap_pvt_thread_yield();
1294 #ifndef HAVE_WINSOCK
1295 /* make sure descriptor number isn't too great */
1296 if ( s >= dtblsize ) {
1298 LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
1299 "slapd_daemon_task: %ld beyond descriptor table size %ld\n",
1300 (long)s, (long)dtblsize ));
1302 Debug( LDAP_DEBUG_ANY,
1303 "daemon: %ld beyond descriptor table size %ld\n",
1304 (long) s, (long) dtblsize, 0 );
1308 ldap_pvt_thread_yield();
1314 ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
1316 /* newly accepted stream should not be in any of the FD SETS */
1317 assert( !FD_ISSET( s, &slap_daemon.sd_actives) );
1318 assert( !FD_ISSET( s, &slap_daemon.sd_readers) );
1319 assert( !FD_ISSET( s, &slap_daemon.sd_writers) );
1321 ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
1324 #if defined( SO_KEEPALIVE ) || defined( TCP_NODELAY )
1325 #ifdef LDAP_PF_LOCAL
1326 /* for IPv4 and IPv6 sockets only */
1327 if ( from.sa_addr.sa_family != AF_LOCAL )
1328 #endif /* LDAP_PF_LOCAL */
1333 /* enable keep alives */
1335 rc = setsockopt( s, SOL_SOCKET, SO_KEEPALIVE,
1336 (char *) &tmp, sizeof(tmp) );
1337 if ( rc == AC_SOCKET_ERROR ) {
1338 int err = sock_errno();
1340 LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
1341 "slapd_daemon_task: setsockopt( %ld, SO_KEEPALIVE) failed errno=%d (%s)\n",
1342 (long)s, err, sock_errstr(err) ));
1344 Debug( LDAP_DEBUG_ANY,
1345 "slapd(%ld): setsockopt(SO_KEEPALIVE) failed "
1346 "errno=%d (%s)\n", (long) s, err, sock_errstr(err) );
1351 /* enable no delay */
1353 rc = setsockopt( s, IPPROTO_TCP, TCP_NODELAY,
1354 (char *)&tmp, sizeof(tmp) );
1355 if ( rc == AC_SOCKET_ERROR ) {
1356 int err = sock_errno();
1358 LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
1359 "slapd_daemon_task: setsockopt( %ld, TCP_NODELAY) failed errno=%d (%s)\n",
1360 (long)s, err, sock_errstr(err) ));
1362 Debug( LDAP_DEBUG_ANY,
1363 "slapd(%ld): setsockopt(TCP_NODELAY) failed "
1364 "errno=%d (%s)\n", (long) s, err, sock_errstr(err) );
1372 LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL1,
1373 "slapd_daemon_task: new connection on %ld\n", (long)s ));
1375 Debug( LDAP_DEBUG_CONNS, "daemon: new connection on %ld\n",
1378 switch ( from.sa_addr.sa_family ) {
1379 # ifdef LDAP_PF_LOCAL
1381 sprintf( peername, "PATH=%s", from.sa_un_addr.sun_path );
1382 ssf = LDAP_PVT_SASL_LOCAL_SSF;
1385 #endif /* LDAP_PF_LOCAL */
1387 # ifdef LDAP_PF_INET6
1389 if ( IN6_IS_ADDR_V4MAPPED(&from.sa_in6_addr.sin6_addr) ) {
1390 peeraddr = inet_ntoa( *((struct in_addr *)
1391 &from.sa_in6_addr.sin6_addr.s6_addr[12]) );
1392 sprintf( peername, "IP=%s:%d",
1393 peeraddr != NULL ? peeraddr : "unknown",
1394 (unsigned) ntohs( from.sa_in6_addr.sin6_port ) );
1396 char addr[INET6_ADDRSTRLEN];
1397 sprintf( peername, "IP=%s %d",
1398 inet_ntop( AF_INET6,
1399 &from.sa_in6_addr.sin6_addr,
1400 addr, sizeof addr) ? addr : "unknown",
1401 (unsigned) ntohs( from.sa_in6_addr.sin6_port ) );
1404 # endif /* LDAP_PF_INET6 */
1407 peeraddr = inet_ntoa( from.sa_in_addr.sin_addr );
1408 sprintf( peername, "IP=%s:%d",
1409 peeraddr != NULL ? peeraddr : "unknown",
1410 (unsigned) ntohs( from.sa_in_addr.sin_port ) );
1418 if ( ( from.sa_addr.sa_family == AF_INET )
1419 #ifdef LDAP_PF_INET6
1420 || ( from.sa_addr.sa_family == AF_INET6 )
1423 #ifdef SLAPD_RLOOKUPS
1424 if ( use_reverse_lookup ) {
1425 # ifdef LDAP_PF_INET6
1426 if ( from.sa_addr.sa_family == AF_INET6 )
1428 (char *)&(from.sa_in6_addr.sin6_addr),
1429 sizeof(from.sa_in6_addr.sin6_addr),
1432 # endif /* LDAP_PF_INET6 */
1434 (char *) &(from.sa_in_addr.sin_addr),
1435 sizeof(from.sa_in_addr.sin_addr),
1437 dnsname = hp ? ldap_pvt_str2lower( hp->h_name ) : NULL;
1441 #endif /* SLAPD_RLOOKUPS */
1444 if ( !hosts_ctl("slapd",
1445 dnsname != NULL ? dnsname : STRING_UNKNOWN,
1446 peeraddr != NULL ? peeraddr : STRING_UNKNOWN,
1450 Statslog( LDAP_DEBUG_ANY,
1451 "fd=%ld host access from %s (%s) denied.\n",
1453 dnsname != NULL ? dnsname : "unknown",
1454 peeraddr != NULL ? peeraddr : "unknown",
1459 #endif /* HAVE_TCPD */
1462 id = connection_init(s,
1463 slap_listeners[l]->sl_url,
1464 dnsname != NULL ? dnsname : "unknown",
1466 slap_listeners[l]->sl_name,
1468 slap_listeners[l]->sl_is_tls,
1475 if( authid ) ch_free(authid);
1479 LDAP_LOG(( "connection", LDAP_LEVEL_INFO,
1480 "slapd_daemon_task: connection_init(%ld, %s, %s) failed.\n",
1481 (long)s, peername, slap_listeners[l]->sl_name ));
1483 Debug( LDAP_DEBUG_ANY,
1484 "daemon: connection_init(%ld, %s, %s) failed.\n",
1487 slap_listeners[l]->sl_name );
1493 Statslog( LDAP_DEBUG_STATS,
1494 "daemon: conn=%ld fd=%ld connection from %s (%s) accepted.\n",
1497 slap_listeners[l]->sl_name,
1506 LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL2,
1507 "slapd_daemon_task: activity on " ));
1509 Debug( LDAP_DEBUG_CONNS, "daemon: activity on:", 0, 0, 0 );
1512 for ( i = 0; i < readfds.fd_count; i++ ) {
1514 LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL2,
1515 " %d%s", readfds.fd_array[i], "r", 0 ));
1517 Debug( LDAP_DEBUG_CONNS, " %d%s",
1518 readfds.fd_array[i], "r", 0 );
1521 for ( i = 0; i < writefds.fd_count; i++ ) {
1523 LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL2,
1524 " %d%s", writefds.fd_array[i], "w" ));
1526 Debug( LDAP_DEBUG_CONNS, " %d%s",
1527 writefds.fd_array[i], "w", 0 );
1532 for ( i = 0; i < nfds; i++ ) {
1534 int is_listener = 0;
1536 for ( l = 0; slap_listeners[l] != NULL; l++ ) {
1537 if ( i == slap_listeners[l]->sl_sd ) {
1538 #ifdef LDAP_CONNECTIONLESS
1539 /* The listener is the data port. Don't
1542 if (slap_listeners[l]->sl_is_udp)
1549 if ( is_listener ) {
1552 r = FD_ISSET( i, &readfds );
1553 w = FD_ISSET( i, &writefds );
1556 LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL2,
1558 r ? "r" : "", w ? "w" : "" ));
1560 Debug( LDAP_DEBUG_CONNS, " %d%s%s", i,
1561 r ? "r" : "", w ? "w" : "" );
1567 LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL2, "\n" ));
1569 Debug( LDAP_DEBUG_CONNS, "\n", 0, 0, 0 );
1574 /* loop through the writers */
1576 for ( i = 0; i < writefds.fd_count; i++ )
1578 for ( i = 0; i < nfds; i++ )
1582 int is_listener = 0;
1584 wd = writefds.fd_array[i];
1586 if( ! FD_ISSET( i, &writefds ) ) {
1592 for ( l = 0; slap_listeners[l] != NULL; l++ ) {
1593 if ( i == slap_listeners[l]->sl_sd ) {
1594 #ifdef LDAP_CONNECTIONLESS
1595 if (slap_listeners[l]->sl_is_udp)
1602 if ( is_listener ) {
1606 LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL2,
1607 "slapd_daemon_task: write active on %d\n", wd ));
1609 Debug( LDAP_DEBUG_CONNS,
1610 "daemon: write active on %d\n",
1614 * NOTE: it is possible that the connection was closed
1615 * and that the stream is now inactive.
1616 * connection_write() must valid the stream is still
1620 if ( connection_write( wd ) < 0 ) {
1621 FD_CLR( (unsigned) wd, &readfds );
1627 for ( i = 0; i < readfds.fd_count; i++ )
1629 for ( i = 0; i < nfds; i++ )
1633 int is_listener = 0;
1636 rd = readfds.fd_array[i];
1638 if( ! FD_ISSET( i, &readfds ) ) {
1644 for ( l = 0; slap_listeners[l] != NULL; l++ ) {
1645 if ( rd == slap_listeners[l]->sl_sd ) {
1646 #ifdef LDAP_CONNECTIONLESS
1647 if (slap_listeners[l]->sl_is_udp)
1654 if ( is_listener ) {
1659 LDAP_LOG(( "connection", LDAP_LEVEL_DETAIL2,
1660 "slapd_daemon_task: read activity on %d\n", rd ));
1662 Debug ( LDAP_DEBUG_CONNS,
1663 "daemon: read activity on %d\n", rd, 0, 0 );
1666 * NOTE: it is possible that the connection was closed
1667 * and that the stream is now inactive.
1668 * connection_read() must valid the stream is still
1672 if ( connection_read( rd ) < 0 ) {
1676 ldap_pvt_thread_yield();
1679 if( slapd_shutdown > 0 ) {
1681 LDAP_LOG(( "connection", LDAP_LEVEL_CRIT,
1682 "slapd_daemon_task: shutdown requested and initiated.\n"));
1684 Debug( LDAP_DEBUG_TRACE,
1685 "daemon: shutdown requested and initiated.\n",
1689 } else if ( slapd_shutdown < 0 ) {
1690 #ifdef HAVE_NT_SERVICE_MANAGER
1691 if (slapd_shutdown == -1)
1694 LDAP_LOG(( "connection", LDAP_LEVEL_CRIT,
1695 "slapd_daemon_task: shutdown initiated by Service Manager.\n"));
1697 Debug( LDAP_DEBUG_TRACE,
1698 "daemon: shutdown initiated by Service Manager.\n",
1706 LDAP_LOG(( "connection", LDAP_LEVEL_CRIT,
1707 "slapd_daemon_task: abnormal condition, shutdown initiated.\n" ));
1709 Debug( LDAP_DEBUG_TRACE,
1710 "daemon: abnormal condition, shutdown initiated.\n",
1716 LDAP_LOG(( "connection", LDAP_LEVEL_CRIT,
1717 "slapd_daemon_task: no active streams, shutdown initiated.\n" ));
1719 Debug( LDAP_DEBUG_TRACE,
1720 "daemon: no active streams, shutdown initiated.\n",
1725 for ( l = 0; slap_listeners[l] != NULL; l++ ) {
1726 if ( slap_listeners[l]->sl_sd != AC_SOCKET_INVALID ) {
1727 #ifdef LDAP_PF_LOCAL
1728 if ( slap_listeners[l]->sl_sa.sa_addr.sa_family == AF_LOCAL ) {
1729 unlink( slap_listeners[l]->sl_sa.sa_un_addr.sun_path );
1731 #endif /* LDAP_PF_LOCAL */
1732 slapd_close( slap_listeners[l]->sl_sd );
1734 if ( slap_listeners[l]->sl_url )
1735 free ( slap_listeners[l]->sl_url );
1736 if ( slap_listeners[l]->sl_name )
1737 free ( slap_listeners[l]->sl_name );
1738 free ( slap_listeners[l] );
1740 free ( slap_listeners );
1741 slap_listeners = NULL;
1744 LDAP_LOG(( "connection", LDAP_LEVEL_CRIT,
1745 "slapd_daemon_task: shutdown waiting for %d threads to terminate.\n",
1746 ldap_pvt_thread_pool_backload(&connection_pool) ));
1748 Debug( LDAP_DEBUG_ANY,
1749 "slapd shutdown: waiting for %d threads to terminate\n",
1750 ldap_pvt_thread_pool_backload(&connection_pool), 0, 0 );
1752 ldap_pvt_thread_pool_destroy(&connection_pool, 1);
1758 int slapd_daemon( void )
1764 #define SLAPD_LISTENER_THREAD 1
1765 #if defined( SLAPD_LISTENER_THREAD )
1767 ldap_pvt_thread_t listener_tid;
1769 /* listener as a separate THREAD */
1770 rc = ldap_pvt_thread_create( &listener_tid,
1771 0, slapd_daemon_task, NULL );
1775 LDAP_LOG(( "connection", LDAP_LEVEL_ERR,
1776 "slapd_daemon: listener ldap_pvt_thread_create failed (%d).\n", rc ));
1778 Debug( LDAP_DEBUG_ANY,
1779 "listener ldap_pvt_thread_create failed (%d)\n", rc, 0, 0 );
1784 /* wait for the listener thread to complete */
1785 ldap_pvt_thread_join( listener_tid, (void *) NULL );
1788 /* experimental code */
1789 slapd_daemon_task( NULL );
1798 #if defined( HAVE_WINSOCK2 )
1799 WORD wVersionRequested;
1803 wVersionRequested = MAKEWORD( 2, 0 );
1805 err = WSAStartup( wVersionRequested, &wsaData );
1807 /* Tell the user that we couldn't find a usable */
1812 /* Confirm that the WinSock DLL supports 2.0.*/
1813 /* Note that if the DLL supports versions greater */
1814 /* than 2.0 in addition to 2.0, it will still return */
1815 /* 2.0 in wVersion since that is the version we */
1818 if ( LOBYTE( wsaData.wVersion ) != 2 ||
1819 HIBYTE( wsaData.wVersion ) != 0 )
1821 /* Tell the user that we couldn't find a usable */
1827 /* The WinSock DLL is acceptable. Proceed. */
1828 #elif defined( HAVE_WINSOCK )
1830 if ( WSAStartup( 0x0101, &wsaData ) != 0 ) {
1837 int sockdestroy(void)
1839 #if defined( HAVE_WINSOCK2 ) || defined( HAVE_WINSOCK )
1846 slap_sig_shutdown( int sig )
1849 LDAP_LOG(( "connection", LDAP_LEVEL_CRIT,
1850 "slap_sig_shutdown: signal %d\n", sig ));
1852 Debug(LDAP_DEBUG_TRACE, "slap_sig_shutdown: signal %d\n", sig, 0, 0);
1856 * If the NT Service Manager is controlling the server, we don't
1857 * want SIGBREAK to kill the server. For some strange reason,
1858 * SIGBREAK is generated when a user logs out.
1861 #if HAVE_NT_SERVICE_MANAGER && SIGBREAK
1862 if (is_NT_Service && sig == SIGBREAK)
1864 LDAP_LOG(( "connection", LDAP_LEVEL_CRIT,
1865 "slap_sig_shutdown: SIGBREAK ignored.\n" ));
1867 Debug(LDAP_DEBUG_TRACE, "slap_sig_shutdown: SIGBREAK ignored.\n",
1872 slapd_shutdown = sig;
1876 /* reinstall self */
1877 (void) SIGNAL_REINSTALL( sig, slap_sig_shutdown );
1881 slap_sig_wake( int sig )
1885 /* reinstall self */
1886 (void) SIGNAL_REINSTALL( sig, slap_sig_wake );
1890 void slapd_add_internal(ber_socket_t s) {
1894 Listener ** slapd_get_listeners(void) {
1895 return slap_listeners;