Fix bug#156: problem with reloading.
authorTatsuo Ishii <ishii@postgresql.org>
Sun, 17 Jan 2016 12:11:31 +0000 (21:11 +0900)
committerTatsuo Ishii <ishii@postgresql.org>
Sun, 17 Jan 2016 12:45:03 +0000 (21:45 +0900)
commitf7c9265e7193ea4221ac6663b3331dac03a619b9
treec9e3e5cd581ac4a088570906ccbc3a8be98f07a9
parentadd25922fad6a8be812bfa450df6814149b63ccd
Fix bug#156: problem with reloading.

While reloading pgpool.conf, the number of DB nodes is tentatively set
to 0, then counted up until reaching to the actual number of backends
by the pgpool main process. Unfortunately the variable is on the
shared memory and it confuses pgpool child process if they are using
the variable. To solve the problem, a local variable is used to count
up the number of backend. After finishing the counting, the value of
the local variable is assigned to the variable on the shared memory.

I will explain why we don't need interlocking:

1) If the number of backend has not changed before/after the loop,
   it's obviously fine.

2) If the number of backend has increased after the loop, the new
   backend is recognized as "CON_UNUSED" because all the status for
   each backend is set to "CON_UNUSED" beforehand.

3) If the number of backend has decreased after the loop, failover
   should have happened and child process should have restarted.

However, we should be careful so that the assignment of the variable
should happen in an atomic manner. For this purpose I change the data
type of the variable from int to sig_atomic_t.
src/config/pool_config.c
src/config/pool_config.l
src/include/pcp/libpcp_ext.h