Fix watchdog communication race condition.
authorTatsuo Ishii <ishii@sraoss.co.jp>
Fri, 21 May 2021 23:00:05 +0000 (08:00 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Sat, 22 May 2021 00:32:47 +0000 (09:32 +0900)
commitd89546b982c16998604bf24772bd161555f13a49
treeb71f6e9a1900086e80bcd512f9ef71fe00b62995
parent95e500c0eb12a8110e8f04e247403c8070de9659
Fix watchdog communication race condition.

Watchdog sends information from the watchdog process to the Pgpool-II
main process using SIGUSR1. To pass detailed messages it uses shared
memory area. First it sets a message to the shared memory area then
sends SIGUSR1 to the main process. The main process received the
signal and the signal handler sets a global variable so that
sigusr1_interrupt_processor() processes it. However it is possible
that while sigusr1_interrupt_processor() is running new signal
arrives. In this case the new signal is caught but the global variable
is set to 0 after sigusr1_interrupt_processor() returns. This means
that the new message is not processed until new signal arrives, which
could cause significant delay before the message was processed.

To fix the problem, sigusr1_interrupt_processor() is repeatedly called
until there's no pending message.

Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2021-May/003901.html
src/main/pgpool_main.c