diff options
Diffstat (limited to 'src/port/noblock.c')
-rw-r--r-- | src/port/noblock.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/port/noblock.c b/src/port/noblock.c index d1431545989..0e31b8f82e1 100644 --- a/src/port/noblock.c +++ b/src/port/noblock.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/port/noblock.c,v 1.5 2004/12/31 22:03:53 pgsql Exp $ + * $PostgreSQL: pgsql/src/port/noblock.c,v 1.5.4.1 2005/03/25 00:35:20 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -18,7 +18,7 @@ #include <fcntl.h> bool -set_noblock(int sock) +pg_set_noblock(int sock) { #if !defined(WIN32) && !defined(__BEOS__) return (fcntl(sock, F_SETFL, O_NONBLOCK) != -1); @@ -34,3 +34,26 @@ set_noblock(int sock) #endif #endif } + + +bool +pg_set_block(int sock) +{ +#if !defined(WIN32) && !defined(__BEOS__) + int flags; + flags = fcntl(sock, F_GETFL); + if (flags < 0 || fcntl(sock, F_SETFL, (long) (flags & ~O_NONBLOCK))) + return false; + return true; +#else + long ioctlsocket_ret = 0; + + /* Returns non-0 on failure, while fcntl() returns -1 on failure */ +#ifdef WIN32 + return (ioctlsocket(sock, FIONBIO, &ioctlsocket_ret) == 0); +#endif +#ifdef __BEOS__ + return (ioctl(sock, FIONBIO, &ioctlsocket_ret) == 0); +#endif +#endif +} |