From 74543e6c68b50b62a82ce32cbbc593e81b68b09f Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Sun, 29 Aug 1999 04:01:16 +0000 Subject: [PATCH] Defined tcp_read and tcp_write. Use them in daemon.c --- include/ac/socket.h | 19 ++++++++++++++++--- servers/slapd/daemon.c | 4 ++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/include/ac/socket.h b/include/ac/socket.h index 48bb031a8c..24dd139f26 100644 --- a/include/ac/socket.h +++ b/include/ac/socket.h @@ -67,8 +67,13 @@ #define MAXHOSTNAMELEN 64 #endif +#define sock_errno() errno +#define sock_errstr() STRERROR(errno) + #ifdef HAVE_WINSOCK -# define tcp_close( s ) closesocket( s ); +# define tcp_close( s ) closesocket( s ) +# define tcp_read( s, buf, len ) recv( s, buf, len, 0 ) +# define tcp_write( s, buf, len ) send( s, buf, len, 0 ) # define ioctl( s, c, a ) ioctlsocket( (s), (c), (a) ) # define ioctl_t u_long # define AC_SOCKET_INVALID ((unsigned int) ~0) @@ -77,18 +82,26 @@ #define EINPROGRESS WSAEINPROGRESS #define ETIMEDOUT WSAETIMEDOUT +#undef sock_errno +#undef sock_errstr #define sock_errno() WSAGetLastError() #define sock_errstr() WSAGetLastErrorString() #elif MACOS # define tcp_close( s ) tcpclose( s ) +# define tcp_read( s, buf, len ) tcpread( s, buf, len ) +# define tcp_write( s, buf, len ) tcpwrite( s, buf, len ) #elif DOS # ifdef PCNFS # define tcp_close( s ) close( s ) +# define tcp_read( s, buf, len ) recv( s, buf, len, 0 ) +# define tcp_write( s, buf, len ) send( s, buf, len, 0 ) # endif /* PCNFS */ # ifdef NCSA # define tcp_close( s ) do { netclose( s ); netshut() } while(0) +# define tcp_read( s, buf, len ) nread( s, buf, len ) +# define tcp_write( s, buf, len ) netwrite( s, buf, len ) # endif /* NCSA */ #elif HAVE_CLOSESOCKET @@ -96,8 +109,8 @@ #else # define tcp_close( s ) close( s ) -# define sock_errno() errno -# define sock_errstr() STRERROR(errno) +# define tcp_read( s, buf, len) read( s, buf, len ) +# define tcp_write( s, buf, len) write( s, buf, len ) #endif /* MACOS */ #ifndef ioctl_t diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index 95a2689731..1ce529f589 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -659,7 +659,7 @@ slapd_daemon_task( if( FD_ISSET( sel_exit_fd, &readfds ) ) { char c; - read( sel_exit_fd, &c, 1 ); + tcp_read( sel_exit_fd, &c, 1 ); continue; } for ( l = 0; slap_listeners[l] != NULL; l++ ) { @@ -1102,7 +1102,7 @@ slap_set_shutdown( int sig ) } } #endif - write( sel_exit_fd, "0", 1 ); + tcp_write( sel_exit_fd, "0", 1 ); /* reinstall self */ (void) SIGNAL( sig, slap_set_shutdown ); } -- 2.39.5