This is the mail archive of the libc-alpha@sourceware.cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Two second shutdown bug in LinuxThreads.


It's possible for a two second delay to be introduced into the main
thread on shut down. This is due to the 2000 millisecond timeout
of the thread manager's call to __poll().

What happens is: the main thread calls pthread_exit() and is
suspended until all other threads call pthread_exit().

The manager may get the signal from the last of these threads
before it reaches the __poll() wait, but after it has already
tested the termination flag set by the signal handler.

Thus the thread(s) won't be collected until __poll() times out
and the main thread is delayed by two seconds.

The suggested fix is to block the signal, and wrap the call
to __poll() with a sigsetjmp/siglongjmp region.

A simpler and more attractive solution is to have the signal handler deliver a
dummy request to the manager's pipe, subject to some simple test to prevent
flooding the pipe (e.g. if the flag is already set, don't bother).

These approaches are only important when the main thread is pending in a wait,
so to avoid introducing latency into the thread manager loop, whatever logic is
introduced to solve the two second hang can be elided when the main thread
termination flag is zero.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]