2 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
3 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
12 #include <ac/signal.h>
13 #include <ac/socket.h>
14 #include <ac/string.h>
16 #include <ac/unistd.h>
19 #include "ldap_defaults.h"
25 int allow_severity = LOG_INFO;
26 int deny_severity = LOG_NOTICE;
27 #endif /* TCP Wrappers */
31 ber_socket_t dtblsize;
33 typedef struct slap_listener {
40 struct sockaddr_in sl_addr;
43 Listener **slap_listeners = NULL;
45 static ber_socket_t wake_sds[2];
47 #define WAKE_LISTENER(w) \
48 do { if (w) tcp_write( wake_sds[1], "0", 1 ); } while(0)
52 extern ldap_pvt_thread_cond_t started_event;
58 volatile sig_atomic_t slapd_shutdown = 0;
60 static ldap_pvt_thread_t listener_tid;
61 static volatile sig_atomic_t slapd_listener = 0;
63 static struct slap_daemon {
64 ldap_pvt_thread_mutex_t sd_mutex;
69 /* In winsock, accept() returns values higher than dtblsize
70 so don't bother with this optimization */
80 * Add a descriptor to daemon control
82 static void slapd_add(ber_socket_t s) {
83 ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
85 assert( !FD_ISSET( s, &slap_daemon.sd_actives ));
86 assert( !FD_ISSET( s, &slap_daemon.sd_readers ));
87 assert( !FD_ISSET( s, &slap_daemon.sd_writers ));
90 if (s >= slap_daemon.sd_nfds) {
91 slap_daemon.sd_nfds = s + 1;
95 FD_SET( s, &slap_daemon.sd_actives );
96 FD_SET( s, &slap_daemon.sd_readers );
98 Debug( LDAP_DEBUG_CONNS, "daemon: added %ld%s%s\n",
100 FD_ISSET(s, &slap_daemon.sd_readers) ? "r" : "",
101 FD_ISSET(s, &slap_daemon.sd_writers) ? "w" : "" );
103 ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
107 * Remove the descriptor from daemon control
109 void slapd_remove(ber_socket_t s, int wake) {
110 ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
112 Debug( LDAP_DEBUG_CONNS, "daemon: removing %ld%s%s\n",
114 FD_ISSET(s, &slap_daemon.sd_readers) ? "r" : "",
115 FD_ISSET(s, &slap_daemon.sd_writers) ? "w" : "" );
117 FD_CLR( s, &slap_daemon.sd_actives );
118 FD_CLR( s, &slap_daemon.sd_readers );
119 FD_CLR( s, &slap_daemon.sd_writers );
121 ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
125 void slapd_clr_write(ber_socket_t s, int wake) {
126 ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
128 assert( FD_ISSET( s, &slap_daemon.sd_actives) );
129 FD_CLR( s, &slap_daemon.sd_writers );
131 ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
135 void slapd_set_write(ber_socket_t s, int wake) {
136 ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
138 assert( FD_ISSET( s, &slap_daemon.sd_actives) );
139 FD_SET( (unsigned) s, &slap_daemon.sd_writers );
141 ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
145 void slapd_clr_read(ber_socket_t s, int wake) {
146 ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
148 assert( FD_ISSET( s, &slap_daemon.sd_actives) );
149 FD_CLR( s, &slap_daemon.sd_readers );
151 ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
155 void slapd_set_read(ber_socket_t s, int wake) {
156 ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
158 assert( FD_ISSET( s, &slap_daemon.sd_actives) );
159 FD_SET( s, &slap_daemon.sd_readers );
161 ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
165 static void slapd_close(ber_socket_t s) {
166 Debug( LDAP_DEBUG_CONNS, "daemon: closing %ld\n",
184 rc = ldap_url_parse( url, &lud );
186 if( rc != LDAP_URL_SUCCESS ) {
187 Debug( LDAP_DEBUG_ANY,
188 "daemon: listen URL \"%s\" parse error=%d\n",
194 if( lud->lud_ldaps ) {
195 Debug( LDAP_DEBUG_ANY,
196 "daemon: TLS not supported (%s)\n",
198 ldap_free_urldesc( lud );
202 if(! lud->lud_port ) {
203 lud->lud_port = port;
207 l.sl_is_tls = lud->lud_ldaps;
209 if(! lud->lud_port ) {
210 lud->lud_port = lud->lud_ldaps ? tls_port : port;
214 port = lud->lud_port;
216 (void) memset( (void*) &l.sl_addr, '\0', sizeof(l.sl_addr) );
218 l.sl_addr.sin_family = AF_INET;
219 l.sl_addr.sin_port = htons( (unsigned short) lud->lud_port );
221 if( lud->lud_host == NULL || lud->lud_host[0] == '\0'
222 || strcmp(lud->lud_host, "*") == 0 )
224 l.sl_addr.sin_addr.s_addr = htonl(INADDR_ANY);
227 /* host or address was specified */
228 if( !inet_aton( lud->lud_host, &l.sl_addr.sin_addr ) ) {
229 struct hostent *he = gethostbyname( lud->lud_host );
231 Debug( LDAP_DEBUG_ANY, "invalid host (%s) in URL: %s",
232 lud->lud_host, url, 0);
233 ldap_free_urldesc( lud );
237 memcpy( &l.sl_addr.sin_addr, he->h_addr,
238 sizeof( l.sl_addr.sin_addr ) );
242 ldap_free_urldesc( lud );
245 if ( (l.sl_sd = socket( AF_INET, SOCK_STREAM, 0 )) == AC_SOCKET_INVALID ) {
246 int err = sock_errno();
247 Debug( LDAP_DEBUG_ANY,
248 "daemon: socket() failed errno=%d (%s)\n", err,
249 sock_errstr(err), 0 );
254 if ( l.sl_sd >= dtblsize ) {
255 Debug( LDAP_DEBUG_ANY,
256 "daemon: listener descriptor %ld is too great %ld\n",
257 (long) l.sl_sd, (long) dtblsize, 0 );
258 tcp_close( l.sl_sd );
264 /* enable address reuse */
266 if ( setsockopt( l.sl_sd, SOL_SOCKET, SO_REUSEADDR,
267 (char *) &tmp, sizeof(tmp) ) == -1 )
269 int err = sock_errno();
270 Debug( LDAP_DEBUG_ANY,
271 "slapd(%ld): setsockopt(SO_REUSEADDR) failed errno=%d (%s)\n",
272 (long) l.sl_sd, err, sock_errstr(err) );
276 /* enable keep alives */
278 if ( setsockopt( l.sl_sd, SOL_SOCKET, SO_KEEPALIVE,
279 (char *) &tmp, sizeof(tmp) ) == -1 )
281 int err = sock_errno();
282 Debug( LDAP_DEBUG_ANY,
283 "slapd(%ld): setsockopt(SO_KEEPALIVE) failed errno=%d (%s)\n",
284 (long) l.sl_sd, err, sock_errstr(err) );
288 /* enable no delay */
290 if ( setsockopt( l.sl_sd, IPPROTO_TCP, TCP_NODELAY,
291 (char *)&tmp, sizeof(tmp) ) )
293 int err = sock_errno();
294 Debug( LDAP_DEBUG_ANY,
295 "slapd(%ld): setsockopt(TCP_NODELAY) failed errno=%d (%s)\n",
296 (long) l.sl_sd, err, sock_errstr(err) );
300 if ( bind( l.sl_sd, (struct sockaddr *) &l.sl_addr, sizeof(l.sl_addr) ) == -1 ) {
301 int err = sock_errno();
302 Debug( LDAP_DEBUG_ANY, "daemon: bind(%ld) failed errno=%d (%s)\n",
303 (long) l.sl_sd, err, sock_errstr(err) );
304 tcp_close( l.sl_sd );
308 l.sl_url = ch_strdup( url );
310 l.sl_name = ch_malloc( sizeof("IP=255.255.255.255:65336") );
311 s = inet_ntoa( l.sl_addr.sin_addr );
312 sprintf( l.sl_name, "IP=%s:%d",
313 s != NULL ? s : "unknown" , port );
315 li = ch_malloc( sizeof( Listener ) );
318 Debug( LDAP_DEBUG_TRACE, "daemon: initialized %s\n",
324 static int sockinit(void);
325 static int sockdestroy(void);
327 int slapd_daemon_init(char *urls, int port, int tls_port )
333 assert( tls_port == 0 );
336 Debug( LDAP_DEBUG_ARGS, "daemon_init: %s (%d/%d)\n",
337 urls ? urls : "<null>", port, tls_port );
339 if( rc = sockinit() ) {
344 dtblsize = sysconf( _SC_OPEN_MAX );
345 #elif HAVE_GETDTABLESIZE
346 dtblsize = getdtablesize();
348 dtblsize = FD_SETSIZE;
352 if(dtblsize > FD_SETSIZE) {
353 dtblsize = FD_SETSIZE;
355 #endif /* !FD_SETSIZE */
357 /* open a pipe (or something equivalent connected to itself).
358 * we write a byte on this fd whenever we catch a signal. The main
359 * loop will be select'ing on this socket, and will wake up when
362 if( (rc = lutil_pair( wake_sds )) < 0 )
364 Debug( LDAP_DEBUG_ANY,
365 "daemon: lutil_pair() failed rc=%d\n", rc, 0, 0 );
369 FD_ZERO( &slap_daemon.sd_readers );
370 FD_ZERO( &slap_daemon.sd_writers );
376 u = str2charray( urls, " " );
378 if( u == NULL || u[0] == NULL ) {
379 Debug( LDAP_DEBUG_ANY, "daemon_init: no urls (%s) provided.\n",
385 for( i=0; u[i] != NULL; i++ ) {
386 Debug( LDAP_DEBUG_TRACE, "daemon_init: listen on %s\n",
391 Debug( LDAP_DEBUG_ANY, "daemon_init: no listeners to open (%s)\n",
397 Debug( LDAP_DEBUG_TRACE, "daemon_init: %d listeners to open...\n",
400 slap_listeners = ch_malloc( (i+1)*sizeof(Listener *) );
402 for(i = 0; u[i] != NULL; i++ ) {
403 slap_listeners[i] = open_listener( u[i], port, tls_port );
405 if( slap_listeners[i] == NULL ) {
410 slap_listeners[i] = NULL;
412 Debug( LDAP_DEBUG_TRACE, "daemon_init: %d listeners opened\n",
416 ldap_pvt_thread_mutex_init( &slap_daemon.sd_mutex );
422 slapd_daemon_destroy(void)
424 connections_destroy();
425 tcp_close( wake_sds[1] );
426 tcp_close( wake_sds[0] );
441 for ( l = 0; slap_listeners[l] != NULL; l++ ) {
442 if ( slap_listeners[l]->sl_sd == AC_SOCKET_INVALID )
445 if ( listen( slap_listeners[l]->sl_sd, 5 ) == -1 ) {
446 int err = sock_errno();
447 Debug( LDAP_DEBUG_ANY,
448 "daemon: listen(%s, 5) failed errno=%d (%s)\n",
449 (long) slap_listeners[l]->sl_url, err,
454 slapd_add( slap_listeners[l]->sl_sd );
458 if ( started_event != NULL ) {
459 ldap_pvt_thread_cond_signal( &started_event );
462 /* initialization complete. Here comes the loop. */
464 while ( !slapd_shutdown ) {
469 #define SLAPD_EBADF_LIMIT 10
472 #define SLAPD_IDLE_CHECK_LIMIT 4
473 time_t last_idle_check = slap_get_time();
480 struct sockaddr_in from;
481 #if defined(SLAPD_RLOOKUPS) || defined(HAVE_TCPD)
487 if( global_idletimeout > 0 && difftime(
488 last_idle_check+global_idletimeout/SLAPD_IDLE_CHECK_LIMIT,
491 connections_timeout_idle(now);
494 FD_ZERO( &writefds );
500 ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
502 #ifdef FD_SET_MANUAL_COPY
503 for( s = 0; s < nfds; s++ ) {
504 if(FD_ISSET( &slap_sd_readers, s )) {
505 FD_SET( s, &readfds );
507 if(FD_ISSET( &slap_sd_writers, s )) {
508 FD_SET( s, &writefds );
512 memcpy( &readfds, &slap_daemon.sd_readers, sizeof(fd_set) );
513 memcpy( &writefds, &slap_daemon.sd_writers, sizeof(fd_set) );
515 FD_SET( wake_sds[0], &readfds );
517 for ( l = 0; slap_listeners[l] != NULL; l++ ) {
518 if ( slap_listeners[l]->sl_sd == AC_SOCKET_INVALID )
520 FD_SET( slap_listeners[l]->sl_sd, &readfds );
524 nfds = slap_daemon.sd_nfds;
529 ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
531 ldap_pvt_thread_mutex_lock( &active_threads_mutex );
533 ldap_pvt_thread_mutex_unlock( &active_threads_mutex );
535 #if defined( HAVE_YIELDING_SELECT ) || defined( NO_THREADS )
538 tvp = at ? &zero : NULL;
541 for ( l = 0; slap_listeners[l] != NULL; l++ ) {
542 if ( slap_listeners[l]->sl_sd == AC_SOCKET_INVALID )
545 Debug( LDAP_DEBUG_CONNS,
546 "daemon: select: listen=%d active_threads=%d tvp=%s\n",
547 slap_listeners[l]->sl_sd, at,
548 tvp == NULL ? "NULL" : "zero" );
551 switch(ns = select( nfds, &readfds,
553 /* don't pass empty fd_set */
554 ( writefds.fd_count > 0 ? &writefds : NULL ),
560 case -1: { /* failure - try again */
561 int err = sock_errno();
563 if( err == EBADF && ++ebadf < SLAPD_EBADF_LIMIT) {
568 Debug( LDAP_DEBUG_CONNS,
569 "daemon: select failed (%d): %s\n",
570 err, sock_errstr(err), 0 );
577 case 0: /* timeout - let threads run */
579 Debug( LDAP_DEBUG_CONNS, "daemon: select timeout - yielding\n",
581 ldap_pvt_thread_yield();
584 default: /* something happened - deal with it */
586 Debug( LDAP_DEBUG_CONNS, "daemon: activity on %d descriptors\n",
591 if( FD_ISSET( wake_sds[0], &readfds ) ) {
593 tcp_read( wake_sds[0], &c, 1 );
597 for ( l = 0; slap_listeners[l] != NULL; l++ ) {
599 socklen_t len = sizeof(from);
605 char peername[sizeof("IP=255.255.255.255:65336")];
607 if ( slap_listeners[l]->sl_sd == AC_SOCKET_INVALID )
610 if ( !FD_ISSET( slap_listeners[l]->sl_sd, &readfds ) )
613 if ( (s = accept( slap_listeners[l]->sl_sd,
614 (struct sockaddr *) &from, &len )) == AC_SOCKET_INVALID )
616 int err = sock_errno();
617 Debug( LDAP_DEBUG_ANY,
618 "daemon: accept(%ld) failed errno=%d (%s)\n",
619 (long) slap_listeners[l]->sl_sd, err,
625 ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
627 /* newly accepted stream should not be in any of the FD SETS */
629 assert( !FD_ISSET( s, &slap_daemon.sd_actives) );
630 assert( !FD_ISSET( s, &slap_daemon.sd_readers) );
631 assert( !FD_ISSET( s, &slap_daemon.sd_writers) );
633 ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex );
637 /* make sure descriptor number isn't too great */
638 if ( s >= dtblsize ) {
639 Debug( LDAP_DEBUG_ANY,
640 "daemon: %ld beyond descriptor table size %ld\n",
641 (long) s, (long) dtblsize, 0 );
647 Debug( LDAP_DEBUG_CONNS, "daemon: new connection on %ld\n",
652 if ( getpeername( s, (struct sockaddr *) &from, &len ) != 0 ) {
653 int err = sock_errno();
654 Debug( LDAP_DEBUG_ANY,
655 "daemon: getpeername( %ld ) failed: errno=%d (%s)\n",
656 (long) s, err, sock_errstr(err) );
661 peeraddr = inet_ntoa( from.sin_addr );
662 sprintf( peername, "IP=%s:%d",
663 peeraddr != NULL ? peeraddr : "unknown",
664 (unsigned) ntohs( from.sin_port ) );
666 #if defined(SLAPD_RLOOKUPS) || defined(HAVE_TCPD)
667 hp = gethostbyaddr( (char *)
668 &(from.sin_addr.s_addr),
669 sizeof(from.sin_addr.s_addr), AF_INET );
672 dnsname = ldap_pvt_str2lower( hp->h_name );
682 if( !hosts_ctl("slapd",
683 dnsname != NULL ? dnsname : STRING_UNKNOWN,
684 peeraddr != NULL ? peeraddr : STRING_UNKNOWN,
688 Statslog( LDAP_DEBUG_ANY,
689 "fd=%ld connection from %s (%s) denied.\n",
691 dnsname != NULL ? dnsname : "unknown",
692 peeraddr != NULL ? peeraddr : "unknown",
698 #endif /* HAVE_TCPD */
700 if( (id = connection_init(s,
701 slap_listeners[l]->sl_url,
702 dnsname != NULL ? dnsname : "unknown",
704 slap_listeners[l]->sl_name,
706 slap_listeners[l]->sl_is_tls
712 Debug( LDAP_DEBUG_ANY,
713 "daemon: connection_init(%ld, %s, %s) failed.\n",
716 slap_listeners[l]->sl_name );
721 Statslog( LDAP_DEBUG_STATS,
722 "daemon: conn=%ld fd=%ld connection from %s (%s) accepted.\n",
725 slap_listeners[l]->sl_name,
733 Debug( LDAP_DEBUG_CONNS, "daemon: activity on:", 0, 0, 0 );
735 for ( i = 0; i < readfds.fd_count; i++ ) {
736 Debug( LDAP_DEBUG_CONNS, " %d%s",
737 readfds.fd_array[i], "r", 0 );
739 for ( i = 0; i < writefds.fd_count; i++ ) {
740 Debug( LDAP_DEBUG_CONNS, " %d%s",
741 writefds.fd_array[i], "w", 0 );
744 for ( i = 0; i < nfds; i++ ) {
748 for ( l = 0; slap_listeners[l] != NULL; l++ ) {
749 if ( i == slap_listeners[l]->sl_sd ) {
757 r = FD_ISSET( i, &readfds );
758 w = FD_ISSET( i, &writefds );
760 Debug( LDAP_DEBUG_CONNS, " %d%s%s", i,
761 r ? "r" : "", w ? "w" : "" );
765 Debug( LDAP_DEBUG_CONNS, "\n", 0, 0, 0 );
768 /* loop through the writers */
770 for ( i = 0; i < writefds.fd_count; i++ )
772 for ( i = 0; i < nfds; i++ )
778 wd = writefds.fd_array[i];
780 if( ! FD_ISSET( i, &writefds ) ) {
786 for ( l = 0; slap_listeners[l] != NULL; l++ ) {
787 if ( i == slap_listeners[l]->sl_sd ) {
795 Debug( LDAP_DEBUG_CONNS,
796 "daemon: write active on %d\n",
800 * NOTE: it is possible that the connection was closed
801 * and that the stream is now inactive.
802 * connection_write() must valid the stream is still
806 if ( connection_write( wd ) < 0 ) {
807 FD_CLR( (unsigned) wd, &readfds );
813 for ( i = 0; i < readfds.fd_count; i++ )
815 for ( i = 0; i < nfds; i++ )
822 rd = readfds.fd_array[i];
824 if( ! FD_ISSET( i, &readfds ) ) {
830 for ( l = 0; slap_listeners[l] != NULL; l++ ) {
831 if ( rd == slap_listeners[l]->sl_sd ) {
840 Debug ( LDAP_DEBUG_CONNS,
841 "daemon: read activity on %d\n", rd, 0, 0 );
844 * NOTE: it is possible that the connection was closed
845 * and that the stream is now inactive.
846 * connection_read() must valid the stream is still
850 if ( connection_read( rd ) < 0 ) {
854 ldap_pvt_thread_yield();
857 if( slapd_shutdown > 0 ) {
858 Debug( LDAP_DEBUG_TRACE,
859 "daemon: shutdown requested and initiated.\n",
862 } else if ( slapd_shutdown < 0 ) {
863 Debug( LDAP_DEBUG_TRACE,
864 "daemon: abnormal condition, shutdown initiated.\n",
867 Debug( LDAP_DEBUG_TRACE,
868 "daemon: no active streams, shutdown initiated.\n",
872 for ( l = 0; slap_listeners[l] != NULL; l++ ) {
873 if ( slap_listeners[l]->sl_sd != AC_SOCKET_INVALID ) {
874 slapd_close( slap_listeners[l]->sl_sd );
879 ldap_pvt_thread_mutex_lock( &active_threads_mutex );
880 Debug( LDAP_DEBUG_ANY,
881 "slapd shutdown: waiting for %d threads to terminate\n",
882 active_threads, 0, 0 );
883 while ( active_threads > 0 ) {
884 ldap_pvt_thread_cond_wait(&active_threads_cond, &active_threads_mutex);
886 ldap_pvt_thread_mutex_unlock( &active_threads_mutex );
892 int slapd_daemon( void )
898 #define SLAPD_LISTENER_THREAD 1
899 #if defined( SLAPD_LISTENER_THREAD ) || !defined(HAVE_PTHREADS)
901 /* listener as a separate THREAD */
902 rc = ldap_pvt_thread_create( &listener_tid,
903 0, slapd_daemon_task, NULL );
906 Debug( LDAP_DEBUG_ANY,
907 "listener ldap_pvt_thread_create failed (%d)\n", rc, 0, 0 );
911 /* wait for the listener thread to complete */
912 ldap_pvt_thread_join( listener_tid, (void *) NULL );
914 /* expermimental code */
915 listener_tid = pthread_self();
916 slapd_daemon_task( NULL );
926 WORD wVersionRequested;
930 wVersionRequested = MAKEWORD( 2, 0 );
932 err = WSAStartup( wVersionRequested, &wsaData );
934 /* Tell the user that we couldn't find a usable */
939 /* Confirm that the WinSock DLL supports 2.0.*/
940 /* Note that if the DLL supports versions greater */
941 /* than 2.0 in addition to 2.0, it will still return */
942 /* 2.0 in wVersion since that is the version we */
945 if ( LOBYTE( wsaData.wVersion ) != 2 ||
946 HIBYTE( wsaData.wVersion ) != 0 )
948 /* Tell the user that we couldn't find a usable */
954 /* The WinSock DLL is acceptable. Proceed. */
958 int sockdestroy(void)
964 void hit_socket(void)
968 extern struct sockaddr_in bind_addr;
970 /* throw something at the socket to terminate the select() in the daemon thread. */
971 if (( s = socket( AF_INET, SOCK_STREAM, 0 )) == AC_SOCKET_INVALID )
972 Debug( LDAP_DEBUG_ANY,
973 "slap_set_shutdown: socket failed\n\tWSAGetLastError=%d (%s)\n",
974 WSAGetLastError(), WSAGetLastErrorString(), 0 );
976 if ( ioctlsocket( s, FIONBIO, &on ) == -1 )
977 Debug( LDAP_DEBUG_ANY,
978 "slap_set_shutdown:FIONBIO ioctl on %d faled\n\tWSAGetLastError=%d (%s)\n",
979 s, WSAGetLastError(), WSAGetLastError() );
981 bind_addr.sin_addr.s_addr = htonl( INADDR_LOOPBACK );
983 if ( connect( s, (struct sockaddr *)&bind_addr, sizeof( struct sockaddr_in )) == SOCKET_ERROR ) {
984 Debug( LDAP_DEBUG_ANY,
985 "hit_socket: error on connect: %d\n",
986 WSAGetLastError(), 0, 0 );
987 /* we can probably expect some error to occur here, mostly WSAEWOULDBLOCK */
994 static int sockinit(void)
996 if ( WSAStartup( 0x0101, &wsaData ) != 0 ) {
1001 static int sockdestroy(void)
1008 static int sockinit(void)
1012 static int sockdestroy(void)
1019 slap_sig_shutdown( int sig )
1021 slapd_shutdown = sig;
1024 /* reinstall self */
1025 (void) SIGNAL( sig, slap_sig_shutdown );
1029 slap_sig_wake( int sig )
1033 /* reinstall self */
1034 (void) SIGNAL( sig, slap_sig_wake );