[Date Prev][Date Next] [Chronological] [Thread] [Top]

(ITS#5248) non-atomic signal variables



Full_Name: Hallvard B Furuseth
Version: HEAD
OS: 
URL: 
Submission from: (NULL) (129.240.6.233)
Submitted by: hallvard


Some non-atomic variables are used both outside and inside signal handlers:

clients/tools/common.c:
	static int	gotintr;
	static int	abcan;
servers/slapd/daemon.c:
	static volatile int waking;
	(used via WAKE_LISTENER in signal handler)
slapd/slapcat.c:
	static int gotsig;

They need to be volatile sig_atomic_t.
That can be signed or unsigned char, so abcan must be set to some
#define in range 0..127 instead of -1.

Two more problems:

WAKE_LISTENER will not be correct anyway since it does '++waking' (not
atomic) and is called both inside and outside a signal handler.
The !NO_THREADS version is OK.

For that matter, behavior is only defined when the signal handler
_writes_ a volatile sig_atomic_t, not when it _reads_ it:
  http://groups.google.no/group/comp.std.c/msg/d01196111ce93615
Dunno what the problem is, or if it is worse than variables
accessed by threads.  I don't see anything to do about it either.