From 2fe4aff20f8a48d76962baea4c83957ec0d6e8b4 Mon Sep 17 00:00:00 2001 From: Tobias Girstmair Date: Wed, 29 May 2024 21:39:53 +0200 Subject: [PATCH] tune connect and setup timeouts it seems some servers have their 'Checking Ident'/'No Ident response' timeout also at roughly 15 seconds, so this can cause a race. giving sockets ten seconds for connect to succeed felt too generous. --- ircpipe.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ircpipe.c b/ircpipe.c index 05839e9..ab2c33a 100644 --- a/ircpipe.c +++ b/ircpipe.c @@ -23,7 +23,8 @@ #define POLL_TIMEOUT 100 /*ms*/ #define PING_INTERVAL 120000 /*ms*/ #define PONG_TIMEOUT 2000 /*ms*/ -#define SETUP_TIMEOUT 15000 /*ms*/ +#define SETUP_TIMEOUT 30000 /*ms*/ +#define SOCKET_TIMEOUT 5000 /*ms*/ #define STR_(x) #x #define STR(x) STR_(x) @@ -67,8 +68,8 @@ sock_t irc_connect(const char *host, const char *port, const int tls, const char int err = getaddrinfo(host, port, NULL, &results); OR_DIE_gai(err); /*unable to resolve*/ - timeout.tv_sec = 10; - timeout.tv_usec = 0; + timeout.tv_sec = SOCKET_TIMEOUT / 1000; + timeout.tv_usec = (SOCKET_TIMEOUT % 1000) * 1000000; for (r = results; r != NULL; r = r->ai_next) { sock.fd = socket(r->ai_family, SOCK_STREAM, 0); -- 2.39.3