HomePhabricator

init: Signal-safe instant shutdown

Description

init: Signal-safe instant shutdown

Summary:

Replace the 200ms polling loop with a faster and more efficient waiting
operation. This should speed up short RPC tests.

This was tried a few times before, but given up every time because
solutions use a condition variable which is not safe for use in signals
as they need to be reentrant.

On UNIX-ish OSes, use a safe way: a pipe. When shutdown is requested
write a dummy byte to the pipe. Waiting for shutdown is a matter of a
blocking read from the pipe.

On Windows, there are no signals so using a condition variable is safe.

This is a backport of core#20605

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D12529

Details

Provenance
Wladimir J. van der Laan <laanwj@protonmail.com>Authored on Dec 8 2020, 20:49
PiRKCommitted on Nov 18 2022, 15:32
PiRKPushed on Nov 18 2022, 15:32
Reviewer
Restricted Project
Differential Revision
D12529: init: Signal-safe instant shutdown
Parents
rABC860a0d7d1372: net: ignore block-relay-only peers when skipping DNS seed
Branches
Unknown
Tags
Unknown

Event Timeline