diff --git a/clients/gopher/go500.c b/clients/gopher/go500.c index 1be51161c0dad271f24d83efe46cbc08c0d096a8..5eca20ad11df9f6e725c8fa2ffce3a3e4068e02a 100644 --- a/clients/gopher/go500.c +++ b/clients/gopher/go500.c @@ -254,7 +254,7 @@ main( int argc, char **argv ) switch( pid = fork() ) { case 0: /* child */ - close( s ); + tcp_close( s ); do_queries( ns ); break; @@ -263,7 +263,7 @@ main( int argc, char **argv ) break; default: /* parent */ - close( ns ); + tcp_close( ns ); if ( debug ) fprintf( stderr, "forked child %d\n", pid ); break; diff --git a/clients/gopher/go500gw.c b/clients/gopher/go500gw.c index b0c1a65d5b2ad8625f74e08ba78855bfb0fe289a..e03bd4b4f821fd3559ecbc940e44857197d31e8e 100644 --- a/clients/gopher/go500gw.c +++ b/clients/gopher/go500gw.c @@ -243,7 +243,7 @@ main (int argc, char **argv ) do_queries( 0 ); - close( 0 ); + tcp_close( 0 ); exit( 0 ); } @@ -280,7 +280,7 @@ main (int argc, char **argv ) switch( pid = fork() ) { case 0: /* child */ - close( s ); + tcp_close( s ); do_queries( ns ); break; @@ -289,7 +289,7 @@ main (int argc, char **argv ) break; default: /* parent */ - close( ns ); + tcp_close( ns ); if ( debug ) fprintf( stderr, "forked child %d\n", pid ); break; diff --git a/include/ac/socket.h b/include/ac/socket.h index 415f5a265fc773e67382838ffe8a16a7d0a044c5..466cccd442eea0495dd6b6251d7d3ddfa1a667b6 100644 --- a/include/ac/socket.h +++ b/include/ac/socket.h @@ -63,22 +63,20 @@ #define MAXHOSTNAMELEN 64 #endif -#ifdef MACOS -#define tcp_close( s ) tcpclose( s ) -#else /* MACOS */ -#ifdef DOS -#ifdef PCNFS -#define tcp_close( s ) close( s ) -#endif /* PCNFS */ -#ifdef NCSA -#define tcp_close( s ) netclose( s ); netshut() -#endif /* NCSA */ -#ifdef WINSOCK -#define tcp_close( s ) closesocket( s ); -#endif /* WINSOCK */ -#else /* DOS */ -#define tcp_close( s ) close( s ) -#endif /* DOS */ +#ifdef HAVE_WINSOCK +# define tcp_close( s ) closesocket( s ); +# define ioctl( s, c, a ) ioctlsocket( (s), (c), (a) ) +#elif MACOS +# define tcp_close( s ) tcpclose( s ) +#elif DOS +# ifdef PCNFS +# define tcp_close( s ) close( s ) +# endif /* PCNFS */ +# ifdef NCSA +# define tcp_close( s ) do { netclose( s ); netshut() } while(0) +# endif /* NCSA */ +#else +# define tcp_close( s ) close( s ) #endif /* MACOS */ #if !defined(__alpha) || defined(VMS) diff --git a/libraries/liblber/sockbuf.c b/libraries/liblber/sockbuf.c index d07926e08e59f6a5953f8425df6e251827fd6c86..1b4adad44d95ba241a644abdc405782602a64aec 100644 --- a/libraries/liblber/sockbuf.c +++ b/libraries/liblber/sockbuf.c @@ -579,8 +579,9 @@ int lber_pvt_sb_set_nonblock( Sockbuf *sb, int nb ) } #ifdef FIONBIO if (lber_pvt_sb_in_use(sb)) { - int status = (nb!=0); - if (ioctl( lber_pvt_sb_get_desc(sb), FIONBIO, (caddr_t)&status ) == -1 ) { + /* WINSOCK requires the status to be a long */ + u_long status = (nb!=0); + if (ioctl( lber_pvt_sb_get_desc(sb), FIONBIO, &status ) == -1 ) { return -1; } } diff --git a/libraries/libldap/cldap.c b/libraries/libldap/cldap.c index 55f1be4fb9faac15ff96755cd9e1ea60ea09f8eb..126e1695b4cbdbb8c13a2f7e554ec649ed4b584b 100644 --- a/libraries/libldap/cldap.c +++ b/libraries/libldap/cldap.c @@ -81,11 +81,11 @@ cldap_open( char *host, int port ) sock.sin_family = AF_INET; sock.sin_port = 0; if ( bind(s, (struct sockaddr *) &sock, sizeof(sock)) < 0) { - close( s ); + tcp_close( s ); return( NULL ); } if (( ld = ldap_init( host, port )) == NULL ) { - close( s ); + tcp_close( s ); return( NULL ); } diff --git a/servers/ldapd/main.c b/servers/ldapd/main.c index 5e91ec6ea31fea8159093d4234c6986ada064e71..3f0e3d3580a15f4a2294fb559e39a58fb0cc7858 100644 --- a/servers/ldapd/main.c +++ b/servers/ldapd/main.c @@ -418,7 +418,7 @@ main( int argc, char **argv ) inet_ntoa( from.sin_addr ) ); } - close(ns); + tcp_close(ns); continue; } #endif /* TCP_WRAPPERS */ @@ -436,7 +436,7 @@ main( int argc, char **argv ) #ifdef VMS /* This is for debug on terminal on VMS */ - close( tcps ); + tcp_close( tcps ); #ifdef LDAP_PROCTITLE setproctitle( hp == NULL ? inet_ntoa( from.sin_addr ) : hp->h_name ); @@ -450,7 +450,7 @@ main( int argc, char **argv ) switch( pid = fork() ) { case 0: /* child */ - close( tcps ); + tcp_close( tcps ); #ifdef LDAP_PROCTITLE sprintf( title, "%s (%d)\n", hp == NULL ? inet_ntoa( from.sin_addr ) : hp->h_name, @@ -467,14 +467,14 @@ main( int argc, char **argv ) #ifdef LDAP_DEBUG if ( ldap_debug ) perror( "fork" ); #endif - close( ns ); + tcp_close( ns ); syslog( LOG_ERR, "fork failed %m" ); /* let things cool off */ sleep( 15 ); break; default: /* parent */ - close( ns ); + tcp_close( ns ); Debug( LDAP_DEBUG_TRACE, "forked child %d\n", pid, 0, 0 ); break; diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index 58954d3026f187619f4a90f1e2b8d7dcbaa5ab93..0f3c859860013d54f15dbb12a2a2faabf722bf71 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -149,7 +149,7 @@ static void slapd_close(int s) { slapd_remove(s); Debug( LDAP_DEBUG_CONNS, "daemon: closing %d\n", s, 0, 0 ); - close(s); + tcp_close(s); } static void * @@ -357,7 +357,7 @@ slapd_daemon_task( Debug( LDAP_DEBUG_ANY, "daemon: %d beyond descriptor table size %d\n", s, dtblsize, 0 ); - close(s); + tcp_close(s); continue; } #endif @@ -409,7 +409,7 @@ slapd_daemon_task( client_addr == NULL ? "unknown" : client_addr, 0, 0 ); - close(s); + tcp_close(s); continue; } #endif /* HAVE_TCPD */ @@ -420,7 +420,7 @@ slapd_daemon_task( s, client_name == NULL ? "unknown" : client_name, client_addr == NULL ? "unknown" : client_addr); - close(s); + tcp_close(s); continue; } @@ -510,7 +510,7 @@ slapd_daemon_task( } if( tcps >= 0 ) { - close( tcps ); + tcp_close( tcps ); } ldap_pvt_thread_mutex_lock( &active_threads_mutex );