Re: Fix Windows socket error checking for MinGW

From: Noah Misch <noah(at)leadboat(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Michael Cronenworth <mike(at)cchtml(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Fix Windows socket error checking for MinGW
Date: 2013-08-20 00:35:00
Message-ID: 20130820003500.GA583089@tornado.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Aug 18, 2013 at 01:02:57PM -0400, Andrew Dunstan wrote:
> On 08/17/2013 01:16 AM, Noah Misch wrote:
>> /*
>> * For Microsoft Visual Studio 2010 and above we intentionally redefine
>> * the regular Berkeley error constants and set them to the WSA constants.
>> * Note that this will break if those constants are used for anything else
>> * than Windows Sockets errors.
>> */
>> #if _MSC_VER >= 1600
>> #pragma warning(disable:4005)
>> #define EMSGSIZE WSAEMSGSIZE
>> #define EAFNOSUPPORT WSAEAFNOSUPPORT
>> #define EWOULDBLOCK WSAEWOULDBLOCK
>> #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
>> #define ECONNRESET WSAECONNRESET
>> #define EINPROGRESS WSAEINPROGRESS
>> #define ENOBUFS WSAENOBUFS
>> #define ECONNREFUSED WSAECONNREFUSED
>> #define EOPNOTSUPP WSAEOPNOTSUPP
>> #pragma warning(default:4005)
>> #endif
>>
>> I suspect we should do one of the following:
>>
>> 1. Redefine those constants for more (all?) compilers.
>> 2. Remove that block and put #ifdef around all usage of such constants in
>> frontend code, as you have done.
>> 3. Remove that block and make src/backend/port/win32/socket.c frontend-usable,
>> so frontend code can treat errno like backend code treats errno.

> There is a much simpler fix, which is to do these assignments
> unconditionally in src/port/win32.h. The following small change fixes
> the problem for me:

That was option #1. (You weren't planning to change just the one symbol
causing the failure at hand, were you?) Reasonable choice. The point in the
code comment quoted above looks bad, but the lack of reports of that nature
against official 9.2 binaries corroborates it having not been a problem yet.
The only non-socket use I see for the constants in question is the EINTR test
in XLogWrite(), which probably can't happen on Windows.

> Note that the original patch appears to be not only misguided but wrong,
> in that it undid a recent important change (commit a099482c) as I read
> it.

Ah; true enough.

Thanks,
nm

--
Noah Misch
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2013-08-20 01:27:57 Re: 9.4 regression
Previous Message Sergey Konoplev 2013-08-20 00:23:28 Re: System catalog vacuum issues