1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-26 12:21:12 +03:00

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.
This commit is contained in:
Tom Lane
2005-03-25 00:34:31 +00:00
parent 46be09e91a
commit e6befdc9d1
9 changed files with 182 additions and 35 deletions

View File

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