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

Commit 80a992d

Browse files
authored
Fix deadlock on SIGHUP (#8918)
Fixes #8892
1 parent c64002e commit 80a992d

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

changelog.d/8918.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix occasional deadlock when handling SIGHUP.

synapse/app/_base.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ def start(hs: "synapse.server.HomeServer", listeners: Iterable[ListenerConfig]):
245245
# Set up the SIGHUP machinery.
246246
if hasattr(signal, "SIGHUP"):
247247

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

265269
signal.signal(signal.SIGHUP, run_sighup)
266270

0 commit comments

Comments
 (0)