From f2e355a5a8e2975f92553b6bd2e50ac5571b985a Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 5 Jun 2026 13:21:26 +0200 Subject: [PATCH] SOCK_Send: retry failed connections very sketchy since idk networking for shit but seems to work so far? --- src/i_tcp.c | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/src/i_tcp.c b/src/i_tcp.c index f7f4a3210..0e6f23f2d 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -753,9 +753,14 @@ static inline ssize_t SOCK_SendToAddr(SOCKET_TYPE socket, mysockaddr_t *sockaddr static void SOCK_Send(void) { - ssize_t c = ERRSOCKET; - int e = 0; // save error code so it can't be modified later code and avoid calling WSAGetLastError() more then once size_t i, j; + int retrycount = 0; + ssize_t c; + int e; // save error code so it can't be modified later code and avoid calling WSAGetLastError() more then once + +retry: + c = ERRSOCKET; + e = 0; if (doomcom->remotenode < 0 || !nodeconnected[doomcom->remotenode]) return; @@ -809,10 +814,32 @@ static void SOCK_Send(void) if (c == ERRSOCKET && e != 0) // 0 means no socket for the address family was found { - if (!ALLOWEDERROR(e)) - I_Error("SOCK_Send, error sending to node %d (%s) #%u, %s", doomcom->remotenode, + if (ALLOWEDERROR(e)) + return; + + //if (!ALLOWEDERROR(e)) + //I_Error("SOCK_Send, error sending to node %d (%s) #%u, %s", doomcom->remotenode, + //SOCK_GetNodeAddress(doomcom->remotenode), e, strerror(e)); + + CONS_Alert(CONS_ERROR, "SOCK_Send, error sending to node %d (%s) #%u, %s", doomcom->remotenode, + SOCK_GetNodeAddress(doomcom->remotenode), e, strerror(e)); + + if (retrycount <= 3) + { + CONS_Printf("SOCK_Send: retrying... Attempt %d", retrycount); + retrycount++; + // wait quarter of a second or smth + I_Sleep(250); + goto retry; + } + + // no recovery + I_Error("SOCK_Send, error sending to node %d (%s) #%u, %s", doomcom->remotenode, SOCK_GetNodeAddress(doomcom->remotenode), e, strerror(e)); } + + if (retrycount > 0) + CONS_Alert(CONS_NOTICE, "SOCK_Send: successfully reconnected on Attempt %d", retrycount); } #undef ALLOWEDERROR