On Mon, Sep 24, 2018 at 09:38:11PM -0400, Tom Lane wrote: > Yeah, in principle any global variable touched by a signal handler should > be sig_atomic_t. I don't know of any modern platform where using "bool" > is unsafe, but per the C standard it could be. The case that would be > worrisome is if setting the variable requires a load/modify/store, which > does apply to char-sized variables on some ancient platforms. I think > there's no need to worry for int-sized variables.
Let's change it then. ClientConnectionLost needs also to be changed as miscadmin.h tells that it could be used in a signal handler. What do you think about the attached? -- Michael
diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c index f7d6617a13..5971310aab 100644 --- a/src/backend/utils/init/globals.c +++ b/src/backend/utils/init/globals.c @@ -27,11 +27,11 @@ ProtocolVersion FrontendProtocol; -volatile bool InterruptPending = false; -volatile bool QueryCancelPending = false; -volatile bool ProcDiePending = false; -volatile bool ClientConnectionLost = false; -volatile bool IdleInTransactionSessionTimeoutPending = false; +volatile sig_atomic_t InterruptPending = false; +volatile sig_atomic_t QueryCancelPending = false; +volatile sig_atomic_t ProcDiePending = false; +volatile sig_atomic_t ClientConnectionLost = false; +volatile sig_atomic_t IdleInTransactionSessionTimeoutPending = false; volatile sig_atomic_t ConfigReloadPending = false; volatile uint32 InterruptHoldoffCount = 0; volatile uint32 QueryCancelHoldoffCount = 0; diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h index e167ee8fcb..8ff106e051 100644 --- a/src/include/miscadmin.h +++ b/src/include/miscadmin.h @@ -77,13 +77,13 @@ /* in globals.c */ /* these are marked volatile because they are set by signal handlers: */ -extern PGDLLIMPORT volatile bool InterruptPending; -extern PGDLLIMPORT volatile bool QueryCancelPending; -extern PGDLLIMPORT volatile bool ProcDiePending; -extern PGDLLIMPORT volatile bool IdleInTransactionSessionTimeoutPending; +extern PGDLLIMPORT volatile sig_atomic_t InterruptPending; +extern PGDLLIMPORT volatile sig_atomic_t QueryCancelPending; +extern PGDLLIMPORT volatile sig_atomic_t ProcDiePending; +extern PGDLLIMPORT volatile sig_atomic_t IdleInTransactionSessionTimeoutPending; extern PGDLLIMPORT volatile sig_atomic_t ConfigReloadPending; -extern volatile bool ClientConnectionLost; +extern volatile sig_atomic_t ClientConnectionLost; /* these are marked volatile because they are examined by signal handlers: */ extern PGDLLIMPORT volatile uint32 InterruptHoldoffCount;
signature.asc
Description: PGP signature