]> granicus.if.org Git - postgresql/commit
Fix latent portability issue in pgwin32_dispatch_queued_signals().
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 4 Apr 2016 15:13:17 +0000 (11:13 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 4 Apr 2016 15:13:30 +0000 (11:13 -0400)
commit7901a7f31fe82bbab8ad701fe04188b985c8f1ec
treeea4664917d74ba6ae7d0bc7f9248308467649561
parente0fb3a20e4941f6be1e8e524b788d6a5c97e0b00
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.
src/backend/port/win32/signal.c