pgsql: Teach WaitEventSetWait() to report multiple events on Windows.

From: Thomas Munro <tmunro(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Teach WaitEventSetWait() to report multiple events on Windows.
Date: 2023-09-08 06:51:34
Message-ID: E1qeVL3-002uxz-Vn@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Teach WaitEventSetWait() to report multiple events on Windows.

The WAIT_USE_WIN32 implementation of WaitEventSetWait() previously
reported at most one event per call, because that's what the underlying
WaitForMultipleObjects() call does.

We can make the behavior match the three Unix implementations by looping
until our output buffer is full, or there are no more events available
now. This makes no difference to most callers including the regular
FEBE socket code, since they ask for at most one event anyway. A
difference in socket accept priority might be perceived by end users
after commit 7389aad6 started using WaitEventSet in the postmaster.
With this commit, the accept order now matches Unix systems, servicing
listening sockets in round-robin order.

We decided it wasn't really a bug or worth back-patching, but it seems
good to align the behavior across platforms.

Reviewed-by: Andres Freund <andres(at)anarazel(dot)de> (earlier version)
Tested-by: "Wei Wang (Fujitsu)" <wangw(dot)fnst(at)fujitsu(dot)com>
Discussion: https://postgr.es/m/CA%2BhUKG%2BA2dk29hr5zRP3HVJQ-_PncNJM6HVQ7aaYLXLRBZU-xw%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/04a09ee944ac904c7fb7ca8f7230a524f514b3e7

Modified Files
--------------
src/backend/storage/ipc/latch.c | 228 +++++++++++++++++++++++-----------------
1 file changed, 132 insertions(+), 96 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Daniel Gustafsson 2023-09-08 09:37:23 pgsql: doc: Extend documentation of PG_TEST_EXTRA
Previous Message Thomas Munro 2023-09-08 05:18:49 pgsql: Remove some more "snapshot too old" vestiges.