-
Notifications
You must be signed in to change notification settings - Fork 428
refactor(store): use dedicated thread for signal handling #840
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
Conversation
|
Problem Our current signal handling logic directly calls cleanupAllResources() inside the signal handler. This causes a deadlock risk: If the signal interrupts a thread that already holds the mutex, the handler will try to lock the same mutex again → self-deadlock. |
|
About the lock and raw ptr, let me think if there's a more elegant solution. But the basic idea is still to let one thread specifically handle signals. I'll get back to you shortly for review. |
|
@ykwd You could review this when you're free.Tks |
ykwd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After thorough offline discussions, we have concluded that the current approach is acceptable.
| sigemptyset(&sa.sa_mask); | ||
| sa.sa_flags = 0; | ||
| sigaction(sig, &sa, nullptr); | ||
| raise(sig); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once it finishes cleanup, it'll re-raise the signal to terminate the whole process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. Thx for clarifying
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a really small gap between them. But I think heartbeat may solve this.
Previous signal handler could potentially deadlock.
This PR uses a thread to process the signal, avoiding this issue.