From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)postgresql(dot)org |
Subject: | pgsql: Fix latent portability issue in pgwin32_dispatch_queued_signals( |
Date: | 2016-04-04 15:14:01 |
Message-ID: | E1an6CX-0001nZ-7b@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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_1_STABLE
Details
-------
http://git.postgresql.org/pg/commitdiff/b1b6aa88b146e0e7ca9b2eb5911d1f56064ccabb
Modified Files
--------------
src/backend/port/win32/signal.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2016-04-04 16:32:47 | pgsql: Introduce a LOG_SERVER_ONLY ereport level, which is never sent t |
Previous Message | Teodor Sigaev | 2016-04-04 11:55:51 | pgsql: Fix typo |