Failproof signal conversion
commit1b1abdba720cfa787f8ecdbd3692db01bc306846
authorPascal Merz <pascal.merz@colorado.edu>
Sat, 20 Oct 2018 15:27:58 +0000 (20 17:27 +0200)
committerMark Abraham <mark.j.abraham@gmail.com>
Mon, 10 Dec 2018 03:50:35 +0000 (10 04:50 +0100)
tree143951d31a12c10c96e5d7da9190fba3f17c857c
parenteaacd177a6aaf17afebe551cb582af70d62c0a10
Failproof signal conversion

When introducing the signal handlers, we decided to use scoped enums to
define the different simulation signals (changes Ia90778, I05ca7a,
I5dec05). In the SimulationSignal objects which actually get reduced,
these are stored as signed char. When the signals get handled, these
signed char are converted back to the scoped enums. Currently, this is
done using a static_cast.

Although in the current code, the signals get handled immediately after
being reduced, and signals are only set by master, there is no formal
guarantee that this is always true. If the signals get reduced multiple
times, or by different ranks, the signed char stored in the
SimulationSignal object could get larger than +1 / -1. In the old code,
this would not lead to problems, as it was just checked that the unsigned
char in the SimulationSignal was != 0 (or <0 / >0, for the stop signal).
In the new code, the signal handling would fail in this case, without
proper error message - the static_cast will not fail, but the following
comparison to the enum values will always fail. This commit introduces
a conversion function for each of the enums and explicity enum values
for the StopSignal to return to the failproof behavior of the old code.

Refs #1793

Change-Id: Iac8ea3946effba1797e16d8c918c7d49ce4dc828
src/gromacs/mdlib/checkpointhandler.cpp
src/gromacs/mdlib/checkpointhandler.h
src/gromacs/mdlib/resethandler.cpp
src/gromacs/mdlib/resethandler.h
src/gromacs/mdlib/stophandler.h