Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Fix deadlock on SIGHUP (#8918)
Browse files Browse the repository at this point in the history
Fixes #8892
  • Loading branch information
erikjohnston authored Dec 10, 2020
1 parent c64002e commit 80a992d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/8918.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix occasional deadlock when handling SIGHUP.
6 changes: 5 additions & 1 deletion synapse/app/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ def start(hs: "synapse.server.HomeServer", listeners: Iterable[ListenerConfig]):
# Set up the SIGHUP machinery.
if hasattr(signal, "SIGHUP"):

reactor = hs.get_reactor()

@wrap_as_background_process("sighup")
def handle_sighup(*args, **kwargs):
# Tell systemd our state, if we're using it. This will silently fail if
Expand All @@ -260,7 +262,9 @@ def handle_sighup(*args, **kwargs):
# is so that we're in a sane state, e.g. flushing the logs may fail
# if the sighup happens in the middle of writing a log entry.
def run_sighup(*args, **kwargs):
hs.get_clock().call_later(0, handle_sighup, *args, **kwargs)
# `callFromThread` should be "signal safe" as well as thread
# safe.
reactor.callFromThread(handle_sighup, *args, **kwargs)

signal.signal(signal.SIGHUP, run_sighup)

Expand Down

0 comments on commit 80a992d

Please sign in to comment.