From: Jeff Johnson <jeff@jeffjohnson.net>
To: 'Bruce Momjian' <pgman@candle.pha.pa.us>
To: jeff@jeffjohnson.net
Cc: pgsql-interfaces@postgresql.org
Cc: pgsql-docs@postgresql.org
Subject: RE: [INTERFACES] libpq sockets on win32
Date: Mon, 4 Jun 2001 15:03:35 -0400
Message-ID: <B9C9130B5D27D4119D5D00A0C9D3A98710945F@SERVER> (raw)
In-Reply-To: <B9C9130B5D27D4119D5D00A0C9D3A987193178@SERVER>
Bruce Momjian wrote:
> Can you try this patch and let me know if it helps? It is a
different
> approach. This was the only place I saw errno checked for a
> non-predefined value.
Setting errno = 0 doesn't help, the error handling code is entered
when recv returns -1, then even if errno == 0, it'll bomb out.
> I hate to litter this through the whole source. I wonder if
> we have to
> bracket the errno checkes with #define/#undef. Can you try that
with
> the fix described on the web page. The above would convert to:
>
> #ifdef WIN32
> #define errno WSAGetLastError
> #endif
> if (errno == EINPROGRESS || errno == 0)
> #ifdef WIN32
> #undef errno
> #endif
>
> Maybe make these into their own macros somehow.
Even when I was a C programmer I never did much more than simple
defines with the pre-compiler so I'll leave this to those that know
how :)
As Tom Lane points out in another post, the "define errno
WSAGetLastError" seems to confuse a variable with a function. I was
surprised that such a thing could work. I'm happy to hear that it
doesn't.
What about something like this:
#ifdef WIN32
#define s_errno WSAGetLastError()
#else
#define s_errno errno
#endif
/* for socket functions, check s_errno */
if (s_errno == EINPROGRESS || s_errno == 0)
...
/* for non-socket functions, check errno as usual */
if (errno == ENOENT)
...
Then replace only errno with s_errno when it is used with socket code.
I'm not sure if strerror would work with all the errors returned by
WSAGetLastError(). The Win32 SDK says to use FormatMessage(a ton of
stuff here).
Regards,
Jeff
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: jeff@jeffjohnson.net, pgman@candle.pha.pa.us, pgsql-docs@postgresql.org
Subject: RE: [INTERFACES] libpq sockets on win32
In-Reply-To: <B9C9130B5D27D4119D5D00A0C9D3A98710945F@SERVER>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox