Rework ac/socket.h for HAVE_WINSOCK:

tcp_close -> closesocket
  ioctl -> ioctlsocket
Modify codes to use tcp_close() instead of close() for sockets.
Modify ioctl codes to be compatible with WINSOCK.
This commit is contained in:
Kurt Zeilenga 1999-03-29 05:15:59 +00:00
parent 30665cb19a
commit ff23537bcb
7 changed files with 34 additions and 35 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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)

View File

@ -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;
}
}

View File

@ -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 );
}

View File

@ -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;

View File

@ -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 );