]> Kevux Git Server - controller/commit
Bugfix: Final clean up thread deadlocks on interrupt.
authorKevin Day <Kevin@kevux.org>
Tue, 29 Jul 2025 02:30:41 +0000 (21:30 -0500)
committerKevin Day <Kevin@kevux.org>
Tue, 29 Jul 2025 02:43:41 +0000 (21:43 -0500)
commit3e9f838e9f67f9bb1a7042e1c24d3f169aa037d7
tree314643bcb01ffd65a505942106005e8f15f0e66e
parentbd2d3c1080a8c1a5a03402ec7021422c6ebeec18
Bugfix: Final clean up thread deadlocks on interrupt.

There is a sleep at the top of the while loop in the clean up thread.
This sleep does not receive interrupts when `PTHREAD_CANCEL_DEFERRED` is set as the cancel state on the thread.

Set the cancel state to `PTHREAD_CANCEL_ASYNCHRONOUS` during the execution of the loop.
This is safe because there are no special locks being held during this sleep at the top of the loop.

Restore the cancel state to `PTHREAD_CANCEL_DEFERRED` once past the sleep.

Add additional checks in the loops for `controller_thread_enabled_e` to potentially catch any situations where an immediate exit would be ideal.
Make sure all locks are unlocked before breaking out of any part of any loop.

Use a try lock when sending signals to child processes rather than a full lock to increase the chance of handling any interrupts.
sources/c/program/controller/main/thread/cleanup.c