Fix pgpool start message printed multiple times.
authorTatsuo Ishii <ishii@postgresql.org>
Wed, 15 Nov 2017 23:12:13 +0000 (08:12 +0900)
committerTatsuo Ishii <ishii@postgresql.org>
Wed, 15 Nov 2017 23:12:13 +0000 (08:12 +0900)
When an exception occurs in the main loop, longjmp() gets called and
the variable "first" restored to the initial value. This make the
pgpool start message printed multiple times. This is harmless but
confusing. To fix that, add "volatile" qualifier so that the variable
is on the stack, rather than on a register.

Fix suggested by Muhammad Usama.

src/main/pgpool_main.c

index cb3bac54ecfe078206591dbe10465638694a9907..1b4da1e50ccb14d115f397f8129c0ee0354d52f2 100644 (file)
@@ -215,7 +215,11 @@ int PgpoolMain(bool discard_status, bool clear_memcache_oidmaps)
 
        sigjmp_buf      local_sigjmp_buf;
 
-       bool first = true;
+       /*
+        * to prevent the variable set on a register so that longjmp() does not
+        * discard the content
+        */
+       volatile bool first = true;
 
        /* For PostmasterRandom */
        gettimeofday(&random_start_time, NULL);