mirror of
https://github.com/SirHumza/orbisRPC.git
synced 2026-10-06 14:00:36 +02:00
WIP: socket timeouts always armed, per-minute alive tick
This commit is contained in:
1 parent
75835fff3b
commit
fca5f17d74
2 files changed
+11
-1
No files matched your search
@@ -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);
|
||||
|
||||
+6
-1
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user