Re: danger

Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: Piete Brooks
Fecha:  
A: Philip Hazel
Cc: Neal Becker, exim-users
Asunto: Re: danger
>> While purusing daemon.c I noticed something that looks rather scary.
>> I see that static void sigchld_handler(int sig) is modifying data
>> structures in the signal handler. This may be asking for trouble.
>> Also, tests of the structure do not seem to be protected with signal
> > blocking.
> This code is exactly the same logic as is used in smail, so if it is
> bad, there's a long-standing problem in smail too! Would anybody else on
> the list care to comment?


Interupt handlers should set flags, or modify "simple" variables.
They should not munge around with objects which are assumed invarient during
certain operations.
This is indeed typically statstructures, but there are cases where it may
cause problems with simple types too ...


if (process early) then do the processing

wait around for some event

if (NOT process early) then do the processing

... unfortunate if "process early" is set during "wait around for some event"