]> git.ipfire.org Git - thirdparty/bind9.git/commit
Make exception/signal handlers idempotent
authorMichał Kępień <michal@isc.org>
Sun, 21 Dec 2025 05:25:56 +0000 (06:25 +0100)
committerMichał Kępień (GitLab job 6657129) <michal@isc.org>
Sun, 21 Dec 2025 06:49:13 +0000 (06:49 +0000)
commitf2b8863691d9c28cb08efcb4dadceb3d09fc1efb
tree000169d63005f802ed128645ecdcd31c0ac23146
parent1ac8e80916e705b32a2849930dd9c535090012e4
Make exception/signal handlers idempotent

Calling asyncio.Future.set_exception() or asyncio.Future.set_result()
more than once for a given Future object raises an
asyncio.InvalidStateError exception.

In the case of AsyncServer:

  - it is enough to capture the first exception raised by higher-level
    logic as no exceptions at all are expected to be raised in the first
    place,

  - no distinction is made between SIGINT and SIGTERM; the only purpose
    of the signal handler is to make the server exit cleanly.

Given the above, make both AsyncServer._handle_exception() and
AsyncServer._signal_done() idempotent by ignoring
asyncio.InvalidStateError exceptions raised by the relevant
asyncio.Future.set_*() calls.

(cherry picked from commit 0ec94e501a04dc6a0730d75e6eeab2782202e16b)
bin/tests/system/isctest/asyncserver.py