diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-03-25 00:34:31 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-03-25 00:34:31 +0000 |
| commit | e6befdc9d1666667835dc49d3b61bb526d74b69d (patch) | |
| tree | 6d08297f9e38a424e2cd7a387c46c8ee71038727 /src/port/noblock.c | |
| parent | 46be09e91aa5a9e1be219f1a8b74621b16b9f2d6 (diff) | |
| download | postgresql-e6befdc9d1666667835dc49d3b61bb526d74b69d.tar.gz | |
Kerberos fixes from Magnus Hagander --- in theory Kerberos 5 auth
should work on Windows now. Also, rename set_noblock to pg_set_noblock;
since it is included in libpq, the former name polluted application
namespace.
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 d143154598..904f40b5df 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.6 2005/03/25 00:34:31 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 +} |
