#include "slap.h"
-#ifdef HAVE_WINSOCK
-#define EWOULDBLOCK WSAEWOULDBLOCK
-#endif
-
/* protected by connections_mutex */
static ldap_pvt_thread_mutex_t connections_mutex;
static Connection *connections = NULL;
}
#endif /* !FD_SETSIZE */
-#ifdef HAVE_WINSOCK
- {
- WORD vers = MAKEWORD( 2, 0);
- int err;
- WSADATA wsaData;
- err = WSAStartup( vers, &wsaData );
- }
-#endif
-
if( addr != NULL ) {
int tmp;
int slapd_daemon( int inetd, int tcps )
{
- int status;
+ int rc;
int *args = ch_malloc( sizeof( int[2] ) );
args[0] = inetd;
args[1] = tcps;
+#ifdef HAVE_WINSOCK
+ {
+ WORD vers = MAKEWORD( 2, 0);
+ int err;
+ WSADATA wsaData;
+ err = WSAStartup( vers, &wsaData );
+ }
+#endif
+
connections_init();
#define SLAPD_LISTENER_THREAD 1
#if SLAPD_LISTENER_THREAD
/* listener as a separate THREAD */
- status = ldap_pvt_thread_create( &listener_tid,
+ rc = ldap_pvt_thread_create( &listener_tid,
0, slapd_daemon_task, args );
- if ( status != 0 ) {
+ if ( rc != 0 ) {
Debug( LDAP_DEBUG_ANY,
- "listener ldap_pvt_thread_create failed (%d)\n", status, 0, 0 );
- return -1;
+ "listener ldap_pvt_thread_create failed (%d)\n", rc, 0, 0 );
+ goto destory;
}
/* wait for the listener thread to complete */
slapd_daemon_task( args );
#endif
+ rc = 0;
+
+destory:
connections_destroy();
- return 0;
+
+#ifdef HAVE_WINSOCK
+ WSACleanup( );
+#endif
+
+ return rc;
}
void