Skip to content

Commit

Permalink
Merge pull request #619 from yarda/sighup-buffer
Browse files Browse the repository at this point in the history
daemon: buffer sighup signal
  • Loading branch information
yarda authored May 23, 2024
2 parents dcce8e3 + ef7cfeb commit ed472f0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tuned/daemon/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,16 @@ 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()
if self._daemon._sighup_processing.is_set():
self._daemon._sighup_pending.set()
else:
do_reload = True
while do_reload:
self._daemon._sighup_processing.set()
self._daemon._sighup_pending.clear()
if not self.reload():
self._daemon._sighup_processing.clear()
do_reload = self._daemon._sighup_pending.is_set()

@exports.signal("sbs")
def profile_changed(self, profile_name, result, errstr):
Expand Down
2 changes: 2 additions & 0 deletions tuned/daemon/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ def _init_threads(self):
self._not_used = threading.Event()
# Flag which is set if SIGHUP is being processed
self._sighup_processing = threading.Event()
# Flag which is set if there is unprocessed SIGHUP pending
self._sighup_pending = threading.Event()
self._not_used.set()
self._profile_applied = threading.Event()

Expand Down

0 comments on commit ed472f0

Please sign in to comment.