Re: Fix Windows socket error checking for MinGW

From: Noah Misch <noah(at)leadboat(dot)com>
To: Michael Cronenworth <mike(at)cchtml(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Fix Windows socket error checking for MinGW
Date: 2013-08-22 03:06:22
Message-ID: 20130822030622.GA606885@tornado.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Noah Misch 2013-08-22 03:24:09 Re: CAST Within EXCLUSION constraint
Previous Message Peter Eisentraut 2013-08-22 03:04:14 Re: docbook-xsl version for release builds