1
0
Fork 0

Merge pull request #547 from yarda/sighup-serialize

Serialize SIGHUP processing
This commit is contained in:
Jaroslav Škarvada 2023-08-17 23:48:27 +02:00 committed by GitHub
commit 6a67b3273e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 1 deletions

View file

@ -67,7 +67,7 @@ class Application(object):
signal.signal(signal_number, handler_wrapper)
def _init_signals(self):
self._handle_signal(signal.SIGHUP, self._controller.reload)
self._handle_signal(signal.SIGHUP, self._controller.sighup)
self._handle_signal(signal.SIGINT, self._controller.terminate)
self._handle_signal(signal.SIGTERM, self._controller.terminate)

View file

@ -70,6 +70,12 @@ class Controller(tuned.exports.interfaces.ExportableInterface):
def terminate(self):
self._terminate.set()
def sighup(self):
if not self._daemon._sighup_processing.is_set():
self._daemon._sighup_processing.set()
if not self.reload():
self._daemon._sighup_processing.clear()
@exports.signal("sbs")
def profile_changed(self, profile_name, result, errstr):
pass

View file

@ -59,6 +59,8 @@ class Daemon(object):
self._terminate_profile_switch = threading.Event()
# Flag which is set if there is no operation in progress
self._not_used = threading.Event()
# Flag which is set if SIGHUP is being processed
self._sighup_processing = threading.Event()
self._not_used.set()
self._profile_applied = threading.Event()
@ -203,6 +205,7 @@ class Daemon(object):
exports.start()
profile_names = " ".join(self._active_profiles)
self._notify_profile_changed(profile_names, True, "OK")
self._sighup_processing.clear()
if self._daemon:
# In python 2 interpreter with applied patch for rhbz#917709 we need to periodically