pgsql-server/src/backend/postmaster postmaster.c

Started by Bruce Momjianover 22 years ago5 messagescomitters
Jump to latest
#1Bruce Momjian
bruce@momjian.us

CVSROOT: /cvsroot
Module name: pgsql-server
Changes by: momjian@svr1.postgresql.org 03/11/10 21:09:42

Modified files:
src/backend/postmaster: postmaster.c

Log message:
* ioctlsocket_ret
- is not initialized to 1 (at least in the WIN_32 code I started with!)

Claudio Natoli

#2Neil Conway
neilc@samurai.com
In reply to: Bruce Momjian (#1)
Re: pgsql-server/src/backend/postmaster postmaster.c

momjian@svr1.postgresql.org (Bruce Momjian) writes:

* ioctlsocket_ret
- is not initialized to 1 (at least in the WIN_32 code I started
with!)

Couldn't we just use a function for FCNTL_NONBLOCK() instead of a
macro, and avoid this "ioctlsocket_ret" hackery?

-Neil

#3Bruce Momjian
bruce@momjian.us
In reply to: Neil Conway (#2)
Re: pgsql-server/src/backend/postmaster postmaster.c

Neil Conway wrote:

momjian@svr1.postgresql.org (Bruce Momjian) writes:

* ioctlsocket_ret
- is not initialized to 1 (at least in the WIN_32 code I started
with!)

Couldn't we just use a function for FCNTL_NONBLOCK() instead of a
macro, and avoid this "ioctlsocket_ret" hackery?

The problem is that the macro needs a holding variable on Win32 and
BeOS:

#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

We define the variable only on Win32/BeOS. Any ideas on how to do this
better?

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#4Neil Conway
neilc@samurai.com
In reply to: Bruce Momjian (#3)
Re: pgsql-server/src/backend/postmaster postmaster.c

Bruce Momjian <pgman@candle.pha.pa.us> writes:

We define the variable only on Win32/BeOS. Any ideas on how to do this
better?

int
set_non_blocking(some_type socket)
{
int ret;

#ifdef SOME_UNIX_PLATFORM
ret = ...;
#else

#ifdef SOME_WINDOWS_PLATFORM
ret = ...;
#else
ret = ...;
#endif

return ret;
}

This function shouldn't be in the critical path for anything, so ISTM
that we can hide this platform-specific ugliness inside a function
without any harm.

-Neil

#5Bruce Momjian
bruce@momjian.us
In reply to: Neil Conway (#4)
Re: pgsql-server/src/backend/postmaster postmaster.c

I have added this to my personal TODO list. Thanks.

---------------------------------------------------------------------------

Neil Conway wrote:

Bruce Momjian <pgman@candle.pha.pa.us> writes:

We define the variable only on Win32/BeOS. Any ideas on how to do this
better?

int
set_non_blocking(some_type socket)
{
int ret;

#ifdef SOME_UNIX_PLATFORM
ret = ...;
#else

#ifdef SOME_WINDOWS_PLATFORM
ret = ...;
#else
ret = ...;
#endif

return ret;
}

This function shouldn't be in the critical path for anything, so ISTM
that we can hide this platform-specific ugliness inside a function
without any harm.

-Neil

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073