Skip site navigation (1) Skip section navigation (2)

pgsql: Attempt to fix some issues in our Windows socket code.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Attempt to fix some issues in our Windows socket code.
Date: 2012-05-13 18:35:52
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-committers
Attempt to fix some issues in our Windows socket code.

Make sure WaitLatchOrSocket regards FD_CLOSE as a read-ready condition.
We might want to tweak this further, but it was surely wrong as-is.

Make pgwin32_waitforsinglesocket detach its private event object from the
passed socket before returning.  I suspect that failure to do so leads
to race conditions when other code (such as WaitLatchOrSocket) attaches
a different event object to the same socket.  Moreover, the existing
coding meant that repeated calls to pgwin32_waitforsinglesocket would
perform ResetEvent on an event actively connected to a socket, which
is rumored to be an unsafe practice; the WSAEventSelect documentation
appears to recommend against this, though it does not say not to do it
in so many words.

Also, uniformly use the coding pattern "WSAEventSelect(s, NULL, 0)" to
detach events from sockets, rather than passing the event in the second
parameter.  The WSAEventSelect documentation says that the second parameter
is ignored if the third is 0, so theoretically this should make no
difference.  However, elsewhere on the same reference page the use of NULL
in this context is recommended, and I have found suggestions on the net
that some versions of Windows have bugs with a non-NULL second parameter
in this usage.

Some other mostly-cosmetic cleanup, such as using the right one of
WSAGetLastError and GetLastError for reporting errors from these functions.



Modified Files
src/backend/port/win32/socket.c |   44 ++++++++++++++++++++++++--------------
src/backend/port/win32_latch.c  |   15 +++++++------
2 files changed, 36 insertions(+), 23 deletions(-)

pgsql-committers by date

Next:From: Tom LaneDate: 2012-05-13 18:52:14
Subject: pgsql: Re-revert stats collector latch changes.
Previous:From: Tom LaneDate: 2012-05-13 04:31:03
Subject: pgsql: Fix bogus declaration of local variable.

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group