Index: src/Makefile.global.in
===================================================================
RCS file: /cvsroot/pgsql-server/src/Makefile.global.in,v
retrieving revision 1.175
diff -c -c -r1.175 Makefile.global.in
*** src/Makefile.global.in	10 Feb 2004 03:42:42 -0000	1.175
--- src/Makefile.global.in	10 Mar 2004 21:03:39 -0000
***************
*** 339,345 ****
  #
  # substitute implementations of the C library
  
! LIBOBJS = @LIBOBJS@ path.o pgsleep.o sprompt.o thread.o
  
  ifneq (,$(LIBOBJS))
  LIBS += -lpgport
--- 339,345 ----
  #
  # substitute implementations of the C library
  
! LIBOBJS = @LIBOBJS@ noblock.o path.o pgsleep.o sprompt.o thread.o
  
  ifneq (,$(LIBOBJS))
  LIBS += -lpgport
Index: src/backend/postmaster/pgstat.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/postmaster/pgstat.c,v
retrieving revision 1.59
diff -c -c -r1.59 pgstat.c
*** src/backend/postmaster/pgstat.c	9 Mar 2004 05:11:52 -0000	1.59
--- src/backend/postmaster/pgstat.c	10 Mar 2004 21:03:42 -0000
***************
*** 327,333 ****
  	 * messages will be discarded; backends won't block waiting to send
  	 * messages to the collector.
  	 */
! 	if (FCNTL_NONBLOCK(pgStatSock) < 0)
  	{
  		ereport(LOG,
  				(errcode_for_socket_access(),
--- 327,333 ----
  	 * messages will be discarded; backends won't block waiting to send
  	 * messages to the collector.
  	 */
! 	if (!set_noblock(pgStatSock))
  	{
  		ereport(LOG,
  				(errcode_for_socket_access(),
***************
*** 1819,1825 ****
  	 * Set the write pipe to nonblock mode, so that we cannot block when
  	 * the collector falls behind.
  	 */
! 	if (FCNTL_NONBLOCK(writePipe) < 0)
  	{
  		ereport(LOG,
  				(errcode_for_socket_access(),
--- 1819,1825 ----
  	 * Set the write pipe to nonblock mode, so that we cannot block when
  	 * the collector falls behind.
  	 */
! 	if (!set_noblock(writePipe))
  	{
  		ereport(LOG,
  				(errcode_for_socket_access(),
Index: src/backend/postmaster/postmaster.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/postmaster/postmaster.c,v
retrieving revision 1.372
diff -c -c -r1.372 postmaster.c
*** src/backend/postmaster/postmaster.c	9 Mar 2004 05:11:52 -0000	1.372
--- src/backend/postmaster/postmaster.c	10 Mar 2004 21:03:44 -0000
***************
*** 219,229 ****
  
  char	   *rendezvous_name;
  
- /* For FNCTL_NONBLOCK */
- #if defined(WIN32) || defined(__BEOS__)
- long		ioctlsocket_ret=1;
- #endif
- 
  /* list of library:init-function to be preloaded */
  char	   *preload_libraries_string = NULL;
  
--- 219,224 ----
***************
*** 2365,2371 ****
  			 strerror(errnum));
  
  	/* Set port to non-blocking.  Don't do send() if this fails */
! 	if (FCNTL_NONBLOCK(port->sock) < 0)
  		return;
  
  	send(port->sock, buffer, strlen(buffer) + 1, 0);
--- 2360,2366 ----
  			 strerror(errnum));
  
  	/* Set port to non-blocking.  Don't do send() if this fails */
! 	if (!set_noblock(port->sock))
  		return;
  
  	send(port->sock, buffer, strlen(buffer) + 1, 0);
Index: src/include/c.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/c.h,v
retrieving revision 1.159
diff -c -c -r1.159 c.h
*** src/include/c.h	10 Jan 2004 23:39:51 -0000	1.159
--- src/include/c.h	10 Mar 2004 21:03:46 -0000
***************
*** 689,708 ****
  #define PG_BINARY_W "w"
  #endif
  
- #if !defined(WIN32) && !defined(__BEOS__)
- #define FCNTL_NONBLOCK(sock)	fcntl(sock, F_SETFL, O_NONBLOCK)
- #else
- extern long ioctlsocket_ret;
- 
- /* Returns non-0 on failure, while fcntl() returns -1 on failure */
- #ifdef WIN32
- #define FCNTL_NONBLOCK(sock)	((ioctlsocket(sock, FIONBIO, &ioctlsocket_ret) == 0) ? 0 : -1)
- #endif
- #ifdef __BEOS__
- #define FCNTL_NONBLOCK(sock)	((ioctl(sock, FIONBIO, &ioctlsocket_ret) == 0) ? 0 : -1)
- #endif
- #endif
- 
  #if defined(sun) && defined(__sparc__) && !defined(__SVR4)
  #include <unistd.h>
  #endif
--- 689,694 ----
Index: src/include/port.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/port.h,v
retrieving revision 1.21
diff -c -c -r1.21 port.h
*** src/include/port.h	9 Mar 2004 04:49:02 -0000	1.21
--- src/include/port.h	10 Mar 2004 21:03:46 -0000
***************
*** 17,22 ****
--- 17,25 ----
  #include <netdb.h>
  #endif
  
+ /* non-blocking */
+ bool set_noblock(int sock);
+ 
  /* Portable path handling for Unix/Win32 */
  extern bool is_absolute_path(const char *filename);
  extern char *first_path_separator(const char *filename);
Index: src/interfaces/libpq/Makefile
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/libpq/Makefile,v
retrieving revision 1.97
diff -c -c -r1.97 Makefile
*** src/interfaces/libpq/Makefile	2 Feb 2004 00:11:31 -0000	1.97
--- src/interfaces/libpq/Makefile	10 Mar 2004 21:03:46 -0000
***************
*** 23,29 ****
  OBJS= fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \
        fe-protocol2.o fe-protocol3.o pqexpbuffer.o pqsignal.o fe-secure.o \
        dllist.o md5.o ip.o wchar.o encnames.o \
!       $(filter crypt.o getaddrinfo.o inet_aton.o snprintf.o strerror.o path.o thread.o, $(LIBOBJS))
  ifeq ($(PORTNAME), win32)
  OBJS+=win32.o
  endif
--- 23,29 ----
  OBJS= fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \
        fe-protocol2.o fe-protocol3.o pqexpbuffer.o pqsignal.o fe-secure.o \
        dllist.o md5.o ip.o wchar.o encnames.o \
!       $(filter crypt.o getaddrinfo.o inet_aton.o nonblock.o snprintf.o strerror.o path.o thread.o, $(LIBOBJS))
  ifeq ($(PORTNAME), win32)
  OBJS+=win32.o
  endif
***************
*** 52,58 ****
  # For port modules, this only happens if configure decides the module
  # is needed (see filter hack in OBJS, above).
  
! crypt.c getaddrinfo.c inet_aton.c snprintf.c strerror.c path.c thread.c: % : $(top_srcdir)/src/port/%
  	rm -f $@ && $(LN_S) $< .
  
  md5.c ip.c: % : $(backend_src)/libpq/%
--- 52,58 ----
  # For port modules, this only happens if configure decides the module
  # is needed (see filter hack in OBJS, above).
  
! crypt.c getaddrinfo.c inet_aton.c nonblock.c snprintf.c strerror.c path.c thread.c: % : $(top_srcdir)/src/port/%
  	rm -f $@ && $(LN_S) $< .
  
  md5.c ip.c: % : $(backend_src)/libpq/%
***************
*** 78,81 ****
  	rm -f $(DESTDIR)$(includedir)/libpq-fe.h $(DESTDIR)$(includedir_internal)/libpq-int.h $(DESTDIR)$(includedir_internal)/pqexpbuffer.h
  
  clean distclean maintainer-clean: clean-lib
! 	rm -f $(OBJS) crypt.c getaddrinfo.c inet_aton.c snprintf.c strerror.c path.c thread.c dllist.c md5.c ip.c encnames.c wchar.c
--- 78,81 ----
  	rm -f $(DESTDIR)$(includedir)/libpq-fe.h $(DESTDIR)$(includedir_internal)/libpq-int.h $(DESTDIR)$(includedir_internal)/pqexpbuffer.h
  
  clean distclean maintainer-clean: clean-lib
! 	rm -f $(OBJS) crypt.c getaddrinfo.c inet_aton.c nonblock.c snprintf.c strerror.c path.c thread.c dllist.c md5.c ip.c encnames.c wchar.c
Index: src/interfaces/libpq/fe-connect.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/libpq/fe-connect.c,v
retrieving revision 1.267
diff -c -c -r1.267 fe-connect.c
*** src/interfaces/libpq/fe-connect.c	9 Jan 2004 02:02:43 -0000	1.267
--- src/interfaces/libpq/fe-connect.c	10 Mar 2004 21:03:49 -0000
***************
*** 50,60 ****
  #include "libpq/ip.h"
  #include "mb/pg_wchar.h"
  
- /* For FNCTL_NONBLOCK */
- #if defined(WIN32) || defined(__BEOS__)
- long		ioctlsocket_ret=1;
- #endif
- 
  #define PGPASSFILE ".pgpass"
  
  /* fall back options if they are not specified by arguments or defined
--- 50,55 ----
***************
*** 779,785 ****
  static int
  connectMakeNonblocking(PGconn *conn)
  {
! 	if (FCNTL_NONBLOCK(conn->sock) < 0)
  	{
  		char		sebuf[256];
  
--- 774,780 ----
  static int
  connectMakeNonblocking(PGconn *conn)
  {
! 	if (!set_noblock(conn->sock))
  	{
  		char		sebuf[256];
  
