Skip to content

Commit 522a665

Browse files
authored
[thread-cert] handle BrokenPipeError on resetting node in simulator (openthread#13495)
When a simulated node restarts (e.g. during `factoryreset`), the child process re-executes itself via `execvp`, disconnecting its UNIX domain socket connection to the virtual-time simulator. If `VirtualTime._send_message()` attempts to send an event before the socket disconnection event has been processed by `selectors`, `sock.send()` raises `BrokenPipeError` or `ConnectionResetError`, even though the node is marked as temporarily offline in `_maybeoff_ports` (via `maybeoff=True`). This commit catches `BrokenPipeError` and `ConnectionResetError` in `VirtualTime._send_message()`, verifying that the destination port is present in `_maybeoff_ports` and skipping delivery cleanly.
1 parent c9d3215 commit 522a665

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

tests/scripts/thread-cert/simulator.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,12 @@ def _send_message(self, message, port):
511511
else:
512512
sock = self.devices[port].get('sock', None)
513513
if sock:
514-
sent = sock.send(message)
514+
try:
515+
sent = sock.send(message)
516+
except (BrokenPipeError, ConnectionResetError):
517+
assert port in self._maybeoff_ports, f'The node {port} is unexpectedly off'
518+
dbg_print('skip sending message to off node', port)
519+
return
515520
else:
516521
assert port in self._maybeoff_ports, f'The node {port} is unexpectedly off'
517522
dbg_print('skip sending message to off node', port)

0 commit comments

Comments
 (0)