Fix watchdog communication race condition.
authorTatsuo Ishii <ishii@sraoss.co.jp>
Fri, 21 May 2021 12:11:27 +0000 (21:11 +0900)
committerTatsuo Ishii <ishii@sraoss.co.jp>
Fri, 21 May 2021 12:11:27 +0000 (21:11 +0900)
commitb52b82c1cc7731d7e1c73ea89ea3baf4b9e1ce1d
tree34bc38890fc50c08b3eddd23f2a6b3b3f45caca8
parent352fe91e1bdc3318d4483ef12eb54f014405f4c0
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