diff options
| author | gbc dev <gbc@localhost> | 2026-07-17 19:46:58 +0200 |
|---|---|---|
| committer | gbc dev <gbc@localhost> | 2026-07-17 19:46:58 +0200 |
| commit | 130215c21ce4aa300abc9a276e2ffb35c8f43803 (patch) | |
| tree | f1298471138095dd98e26ee8c0f9c80cc93e5ce3 /src/gb.h | |
| parent | main: silence stderr while the live sixel display is up (diff) | |
| download | sl0pboy-130215c21ce4aa300abc9a276e2ffb35c8f43803.tar.gz sl0pboy-130215c21ce4aa300abc9a276e2ffb35c8f43803.tar.xz sl0pboy-130215c21ce4aa300abc9a276e2ffb35c8f43803.zip | |
gb: auto-reconnect a dead --serial-sock link instead of going silent
Root-cause work for the 'idle link-socket drop' (see gbos
docs/link-drop-investigation.md): when the hub restarts or the bridge
dies, the link fd went dead forever - and before SIGPIPE was ignored,
the next console-echo write() would kill the whole emulator silently.
Now, in --serial-sock mode, EOF on read or EPIPE/ECONNRESET/ENOTCONN/
EBADF on either direction marks the link dead, closes the fd, and
retries connect() every 500ms from the serial poll path (the guest
polls constantly, so no extra plumbing). RX stays pending while down
(serial_no_eof semantics), so the guest just sees a quiet link that
comes back. Logs 'link socket lost / reconnected' either way.
Verified: SIGKILL the hub, restart it - every GB reconnects within ~1s
and keeps its lease.
Diffstat (limited to 'src/gb.h')
| -rw-r--r-- | src/gb.h | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -117,6 +117,12 @@ struct GB { bool serial_log; // print serial output to stderr (blargg tests) int serial_out_fd; // if >=0, transmitted serial bytes written here (stdout) int serial_in_fd; // if >=0, received serial bytes read here (stdin), else 0xFF + // Link-over-unix-socket resilience: when serial_sock_path is set, a dead + // socket (EOF / EPIPE / ECONNRESET) is closed and reconnected in the + // background instead of going silently dead forever. See serial_check(). + const char *serial_sock_path; // --serial-sock path (NULL = stdio serial) + bool serial_sock_dead; // link socket lost; reconnect pending + double serial_retry_at; // CLOCK_MONOTONIC time of next reconnect try bool poweroff; // set by the $ED opcode: request a clean emulator exit // Boot ROM (BIOS). When boot_rom is non-NULL, gb_reset starts execution |
