Re: Fix Windows socket error checking for MinGW - Mailing list pgsql-hackers

From Noah Misch
Subject Re: Fix Windows socket error checking for MinGW
Date
Msg-id 20130822030622.GA606885@tornado.leadboat.com
Whole thread Raw
In response to Re: Fix Windows socket error checking for MinGW  (Michael Cronenworth <mike@cchtml.com>)
Responses Re: Fix Windows socket error checking for MinGW
List pgsql-hackers
On Mon, Aug 19, 2013 at 08:46:11AM -0500, Michael Cronenworth wrote:
> On 08/17/2013 12:16 AM, Noah Misch wrote:
> > 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.
> > 
> > What do you recommend?
> 
> Option 1 is dangerous. I'd rather let the environments keep their constants.

I concur, but our field experience doing it this way lessens my concern.

> Option 2 is the least dangerous but it adds lines of code.

More than that, as Robert explained, we seek to _isolate_ Windows-specific
code.  That's true even when a better-isolated approach takes more lines.

> Option 3: The errno variable is not set in Windows so relying on it is not possible.

Look at src/backend/port/win32/socket.c; it emulates POSIX socket interfaces
on Windows, and that emulation includes setting errno.  I'd favor option 3 if
we weren't already successfully using option 1 for Visual Studio 2010, the
compiler of official 9.2 and 9.3 binaries.  Since we have been doing that, I
figure changing to option 3 now is riskier than staying the course.

nm

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



pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: docbook-xsl version for release builds
Next
From: Noah Misch
Date:
Subject: Re: CAST Within EXCLUSION constraint