pgsql: Fix latent portability issue in pgwin32_dispatch_queued_signals( - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Fix latent portability issue in pgwin32_dispatch_queued_signals(
Date
Msg-id E1an6CX-0001nX-7Y@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix latent portability issue in pgwin32_dispatch_queued_signals().

The first iteration of the signal-checking loop would compute sigmask(0)
which expands to 1<<(-1) which is undefined behavior according to the
C standard.  The lack of field reports of trouble suggest that it
evaluates to 0 on all existing Windows compilers, but that's hardly
something to rely on.  Since signal 0 isn't a queueable signal anyway,
we can just make the loop iterate from 1 instead, and save a few cycles
as well as avoiding the undefined behavior.

In passing, avoid evaluating the volatile expression UNBLOCKED_SIGNAL_QUEUE
twice in a row; there's no reason to waste cycles like that.

Noted by Aleksander Alekseev, though this isn't his proposed fix.
Back-patch to all supported branches.

Branch
------
REL9_2_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/5496c75de7140e0fedf2fba70bd2df08743d6a64

Modified Files
--------------
src/backend/port/win32/signal.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Fix latent portability issue in pgwin32_dispatch_queued_signals(
Next
From: Tom Lane
Date:
Subject: pgsql: Introduce a LOG_SERVER_ONLY ereport level, which is never sent t