Thread: pgsql: Provide errno-translation wrappers around bind() and listen() on

Provide errno-translation wrappers around bind() and listen() on Windows.

I've seen one too many "could not bind IPv4 socket: No error" log entries
from the Windows buildfarm members.  Per previous discussion, this is
likely caused by the fact that we're doing nothing to translate
WSAGetLastError() to errno.  Put in a wrapper layer to do that.

If this works as expected, it should get back-patched, but let's see what
happens in the buildfarm first.

Discussion: <4065.1452450340@sss.pgh.pa.us>

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/d1b7d4877b9a71f476e8e5adea3b6afe419896ba

Modified Files
--------------
src/backend/port/win32/socket.c | 24 ++++++++++++++++++++++++
src/include/port/win32.h        |  4 ++++
2 files changed, 28 insertions(+)


Re: pgsql: Provide errno-translation wrappers around bind() and listen() on

From
David Rowley
Date:
On 13 April 2016 at 11:52, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Provide errno-translation wrappers around bind() and listen() on Windows.
>
> I've seen one too many "could not bind IPv4 socket: No error" log entries
> from the Windows buildfarm members.  Per previous discussion, this is
> likely caused by the fact that we're doing nothing to translate
> WSAGetLastError() to errno.  Put in a wrapper layer to do that.
>
> If this works as expected, it should get back-patched, but let's see what
> happens in the buildfarm first.
>
> Discussion: <4065.1452450340@sss.pgh.pa.us>

My windows machine gives me a bunch of new warnings with this:

  src/backend/libpq/auth.c(1620): warning C4047: 'function' : 'int *'
differs in levels of indirection from 'size_t'
[L:\Projects\Postgres\a\postgres.vcxproj]
  src/backend/libpq/auth.c(1620): warning C4024: 'pgwin32_bind' :
different types for formal and actual parameter 3
[L:\Projects\Postgres\a\postgres.vcxproj]
  src/backend/libpq/auth.c(2606): warning C4047: 'function' : 'int *'
differs in levels of indirection from 'int'
[L:\Projects\Postgres\a\postgres.vcxproj]
  src/backend/libpq/auth.c(2606): warning C4024: 'pgwin32_bind' :
different types for formal and actual parameter 3
[L:\Projects\Postgres\a\postgres.vcxproj]
  src/backend/libpq/pqcomm.c(493): warning C4047: 'function' : 'int *'
differs in levels of indirection from 'size_t'
[L:\Projects\Postgres\a\postgres.vcxproj]
  src/backend/libpq/pqcomm.c(493): warning C4024: 'pgwin32_bind' :
different types for formal and actual parameter 3
[L:\Projects\Postgres\a\postgres.vcxproj]
  src/backend/port/win32/socket.c(272): warning C4047: 'function' :
'int' differs in levels of indirection from 'int *'
[L:\Projects\Postgres\a\postgres.vcxproj]
  src/backend/port/win32/socket.c(272): warning C4024: 'bind' :
different types for formal and actual parameter 3
[L:\Projects\Postgres\a\postgres.vcxproj]
  src/backend/postmaster/pgstat.c(396): warning C4047: 'function' :
'int *' differs in levels of indirection from 'size_t'
[L:\Projects\Postgres\a\postgres.vcxproj]
  src/backend/postmaster/pgstat.c(396): warning C4024: 'pgwin32_bind'
: different types for formal and actual parameter 3
[L:\Projects\Postgres\a\postgres.vcxproj]

I'm not really sure why you made pgwin32_bind take a pointer to an
int, instead of just an int. I assume a mistake?

The attached fixes and gets rid of the warnings.

Attachment
David Rowley <david.rowley@2ndquadrant.com> writes:
> On 13 April 2016 at 11:52, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Provide errno-translation wrappers around bind() and listen() on Windows.

> I'm not really sure why you made pgwin32_bind take a pointer to an
> int, instead of just an int. I assume a mistake?

Sheer brain fade, exacerbated by not looking closely at the buildfarm
results :-(

Thanks for the patch, pushed.

            regards, tom lane