[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Talarm() problem



> > No, MiNT doesn't have the braindead SYSV signals. It has BSD signals,
> > which don't get zapped when the signal has occured.
> 
>  That completely fits to my prior experiences :-) but doesn't really cure
> my problem :-(

The problem is indeed caused by the interaction of the two timeouts (one
from Fselect the other from Talarm).

If you look at the Fselect code you will notice that canceltimeout() is
always called, even if the timeout has already expired (ie the timeout
function was called and the timeout structure removed from the internal
list).

If addtimeout() is called (from the same process that does Fselect)
after the Fselect timeout expired and before Fselect() calls canceltimeout(),
then most probably the canceltimeout() in Fselect() will cancel the newly
allocated timeout (because the new and the old timeout might get the same
location in memory).

The above mentioned addtimeout() is done by Talarm in the signal handler.

If you look at canceltimeout() in timeout.c you will realize that it works
ONLY correctly if called on timeouts that have NOT expired yet.

One possible bug fix is to NOT free the timeout structure when the timeout
expires but to keep the structure somewhere until a canceltimeout() is done.

Other methods like first checking if the timeout has expired and not calling
canceltimeout() then would require major changes all over the place.

If noone has a better idea I will implement the 'sticky timeouts' and send
diffs.

Kay.