]> git.ipfire.org Git - thirdparty/rspamd.git/commit
[Fix] Keep srv events active during shutdown to track auxiliary processes 5728/head
authorVsevolod Stakhov <vsevolod@rspamd.com>
Tue, 4 Nov 2025 10:54:06 +0000 (10:54 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Tue, 4 Nov 2025 10:54:06 +0000 (10:54 +0000)
commit33d6eed59ca38e18bb46a0f63075b53e679a60b9
tree6fce642e48034893cec78f8bb8af78bb88ca4813
parentbf4b498aef738a18e732ff63f1ddaf7bcf52569f
[Fix] Keep srv events active during shutdown to track auxiliary processes

When Rspamd shuts down with auxiliary processes running (e.g., neural network
training spawned by workers), the main process was stopping srv_pipe event
handlers immediately after sending SIGTERM to workers. This prevented workers
from sending RSPAMD_SRV_ON_FORK notifications when their auxiliary child
processes terminated, causing these children to remain tracked indefinitely.

The main process would then hang for 90 seconds waiting for already-dead
processes that it couldn't properly clean up from the workers hash table.

Root cause analysis:
- Direct workers have ev_child watchers and are removed via SIGCHLD handler
- Auxiliary processes (fork from workers) have NO ev_child watchers
- They are removed ONLY via srv_pipe notifications (RSPAMD_SRV_ON_FORK)
- Stopping srv events during shutdown breaks this notification channel

The original stop_srv_ev code was added in 2019 (commit eafdd221) to avoid
"false notifications" during a major refactoring. However, this is no longer
an issue because:
1. srv_ev handlers automatically stop on EOF when worker pipes close
2. There is no risk of duplicate notifications
3. Auxiliary processes critically need these events to report termination

Solution: Remove the stop_srv_ev call from rspamd_term_handler. This allows
workers to continue sending process termination notifications during shutdown.
The srv_ev handlers will stop naturally when workers close their pipes.

Fixes: #5689, #5694
src/rspamd.c