postgresql/src/backend/port
Tom Lane 001362cfdc Fix race condition in our Windows signal emulation.
pg_signal_dispatch_thread() responded to the client (signal sender)
and disconnected the pipe before actually setting the shared variables
that make the signal visible to the backend process's main thread.
In the worst case, it seems, effective delivery of the signal could be
postponed for as long as the machine has any other work to do.

To fix, just move the pg_queue_signal() call so that we do it before
responding to the client.  This essentially makes pgkill() synchronous,
which is a stronger guarantee than we have on Unix.  That may be
overkill, but on the other hand we have not seen comparable timing bugs
on any Unix platform.

While at it, add some comments to this sadly underdocumented code.

Problem diagnosis and fix by Amit Kapila; I just added the comments.

Back-patch to all supported versions, as it appears that this can cause
visible NOTIFY timing oddities on all of them, and there might be
other misbehavior due to slow delivery of other signals.

Discussion: https://postgr.es/m/32745.1575303812@sss.pgh.pa.us
2019-12-09 15:03:51 -05:00
..
aix Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
hpux Redefine Datum as uintptr_t, instead of unsigned long. 2009-12-31 19:41:37 +00:00
tas Update copyright for 2019 2019-01-02 12:44:25 -05:00
win32 Fix race condition in our Windows signal emulation. 2019-12-09 15:03:51 -05:00
.gitignore Refactor dlopen() support 2018-09-06 11:33:04 +02:00
atomics.c Update copyright for 2019 2019-01-02 12:44:25 -05:00
Makefile Refactor dlopen() support 2018-09-06 11:33:04 +02:00
posix_sema.c Update copyright for 2019 2019-01-02 12:44:25 -05:00
sysv_sema.c Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
sysv_shmem.c Update stale comments, and fix comment typos. 2019-06-08 10:12:26 -07:00
win32_sema.c Update copyright for 2019 2019-01-02 12:44:25 -05:00
win32_shmem.c Consistently test for in-use shared memory. 2019-04-12 22:36:38 -07:00