Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that only 1 signal handler runs at a time #95

Closed
wants to merge 1 commit into from

Conversation

lulf
Copy link

@lulf lulf commented Aug 22, 2016

When I ran qdrouterd with perf and pressed Ctrl+C, perf would send SIGTERM as well as SIGINT right after each other to the router.

Scenario:

Tthe first thread would pick up and handle the first signal in handle_signals_LH(). However, within the function, it unlocks the qd_server->lock before calling the registered handler.

When it unlocks this lock, some other thread will pick up the second signal and jump into the qd_server_pause() code, where it will wait indefinitely for threads to pause (I saw this in GDB, where 1 thread was 'missing', and all others marked as canceled). The original handler will have canceled the thread trying to pause all others, but it is not able to jump out.

This patch ensures that only 1 signal handler can run at a time, which fixes the issue for me. Maybe another approach involving a signal handler lock would be better, but this signal_handler_running variable is protected by the qd_server->lock lock.

@lulf lulf closed this Aug 23, 2016
@lulf lulf deleted the lulf/serialize-signal-handling branch August 23, 2016 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant