Use volatile pointer for Req_info variable.
authorTatsuo Ishii <ishii@postgresql.org>
Tue, 16 May 2017 10:59:56 +0000 (19:59 +0900)
committerTatsuo Ishii <ishii@postgresql.org>
Tue, 16 May 2017 11:04:39 +0000 (20:04 +0900)
Since Req_info points to shared memory area, using volatile pointer
will allow to fetch the fresh value.

src/include/pool.h
src/main/pgpool_main.c
src/test/regression/tests/010.rewrite_timestamp/timestamp/main.c

index f618435bf25a94b15285de436f9c01ac4413d5c8..e8432eb038822d2ca877f83ba233849f56cf928d 100644 (file)
@@ -490,7 +490,7 @@ extern int my_proc_id;  /* process table id (!= UNIX's PID) */
 extern POOL_SYSTEMDB_CONNECTION_POOL *system_db_info; /* systemdb */
 extern ProcessInfo *process_info; /* shmem process information table */
 extern ConnectionInfo *con_info; /* shmem connection info table */
-extern POOL_REQUEST_INFO *Req_info;
+extern volatile POOL_REQUEST_INFO *Req_info;
 extern volatile sig_atomic_t *InRecovery;
 extern char remote_ps_data[];          /* used for set_ps_display */
 extern volatile sig_atomic_t got_sighup;
index bf10f9ce08aaeab267d9d8e7820f748be1fdb6d0..ef4a4395d1265aaad3d9591ac5b3feb515ff7872 100644 (file)
@@ -158,7 +158,7 @@ extern char hba_file[POOLMAXPATHLEN+1];
 static int exiting = 0;                /* non 0 if I'm exiting */
 static int switching = 0;              /* non 0 if I'm fail overing or degenerating */
 
-POOL_REQUEST_INFO *Req_info;           /* request info area in shared memory */
+volatile POOL_REQUEST_INFO *Req_info;          /* request info area in shared memory */
 volatile sig_atomic_t *InRecovery; /* non 0 if recovery is started */
 volatile sig_atomic_t reload_config_request = 0;
 static volatile sig_atomic_t failover_request = 0;
index 5f12a23428ba266ac8a4f5d0f1b77bbc7d4d76e6..993a9cd106e4ed8f32c260c7d44a8c4a4ca97d0c 100644 (file)
@@ -9,7 +9,7 @@
 
 /* for get_current_timestamp() (MASTER() macro) */
 POOL_REQUEST_INFO              _req_info;
-POOL_REQUEST_INFO *Req_info = &_req_info;
+volatile POOL_REQUEST_INFO *Req_info = &_req_info;
 POOL_CONFIG _pool_config;
 POOL_CONFIG *pool_config = &_pool_config;
 ProcessType processType;