diff --git a/orbisrpc/daemon.c b/orbisrpc/daemon.c index fe9f2cf..1d463ac 100644 --- a/orbisrpc/daemon.c +++ b/orbisrpc/daemon.c @@ -168,12 +168,17 @@ int daemon_run(const char *fixed_game_name){ static char cand_title[16] = ""; static int cand_hits = 0, miss_hits = 0; int64_t last_poll = 0; + int64_t last_alive = 0; /* re-post after every (re)connect so Discord never sticks on stale */ int need_post = active && last[0]; while(!s_stop){ /* inner: live session, serviced every second */ int64_t now = orbis_mono_s(); if(now != last_poll){ last_poll = now; + if(now - last_alive >= 60){ + last_alive = now; + log_msg("alive: %s", active ? last : "idle"); + } char name[128] = ""; if(fixed_game_name){ strncpy(name, fixed_game_name, sizeof name-1); diff --git a/orbisrpc/ws.c b/orbisrpc/ws.c index 0a3ac34..60ffa87 100644 --- a/orbisrpc/ws.c +++ b/orbisrpc/ws.c @@ -113,8 +113,13 @@ int ws_connect(ws_t *w, const char *host, int port, const char *resource, const } freeaddrinfo(res); { - struct timeval tv0 = { .tv_sec = 0, .tv_usec = 0 }; + /* Both timeouts stay armed for the socket's whole life (plus + * NBIO below): a stuck peer can never wedge the daemon silently — + * the failure observed on hardware was a frozen process with zero + * output and no timeout to break it. */ + struct timeval tv0 = { .tv_sec = 15, .tv_usec = 0 }; setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv0, sizeof tv0); + setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv0, sizeof tv0); } { int fl = fcntl(fd, F_GETFL, 0);