pgsql: Allow latches to wait for socket writability without waiting for

Поиск
Список
Период
Сортировка
От Andres Freund
Тема pgsql: Allow latches to wait for socket writability without waiting for
Дата
Msg-id E1YB0Jl-00081g-Cc@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Allow latches to wait for socket writability without waiting for readability.

So far WaitLatchOrSocket() required to pass in WL_SOCKET_READABLE as
that solely was used to indicate error conditions, like EOF. Waiting
for WL_SOCKET_WRITEABLE would have meant to busy wait upon socket
errors.

Adjust the API to signal errors by returning the socket as readable,
writable or both, depending on WL_SOCKET_READABLE/WL_SOCKET_WRITEABLE
being specified.  It would arguably be nicer to return WL_SOCKET_ERROR
but that's not possible on platforms and would probably also result in
more complex callsites.

This previously had explicitly been forbidden in e42a21b9e6c9, as
there was no strong use case at that point. We now are looking into
making FE/BE communication use latches, so changing this makes sense.

There also are some portability concerns because there cases of older
platforms where select(2) is known to, in violation of POSIX, not
return a socket as writable after the peer has closed it.  So far the
platforms where that's the case provide a working poll(2). If we find
one where that's not the case, we'll need to add a workaround for that
platform.

Discussion: 20140927191243.GD5423@alap3.anarazel.de
Reviewed-By: Heikki Linnakangas, Noah Misch

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/4bad60e3fd9a5fc6070fd4d1bd820a280e174654

Modified Files
--------------
src/backend/port/unix_latch.c  |   31 ++++++++++++++++++++++++-------
src/backend/port/win32_latch.c |   15 ++++++++++-----
2 files changed, 34 insertions(+), 12 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: pgsql: Fix typos in comment.
Следующее
От: Andres Freund
Дата:
Сообщение: pgsql: Add barriers to the latch code.