From fa6cae0a1729e7141d3159b984a0b00f87284cf7 Mon Sep 17 00:00:00 2001 From: Michael Ortmann Date: Sat, 13 Jun 2026 01:59:57 +0200 Subject: [PATCH 1/4] Enhance log --- src/net.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/net.c b/src/net.c index 9328f1fc8..0fc819cbd 100644 --- a/src/net.c +++ b/src/net.c @@ -1024,11 +1024,10 @@ int sockread(char *s, int *len, sock_list *slist, int slistmax, int tclonly) * otherwise it will connect. */ *len = slist[i].sock; slist[i].flags &= ~SOCK_CONNECT; - debug1("net: eof!(read) socket %d", slist[i].sock); + debug2("net: eof!(read) socket %d error %s", slist[i].sock, strerror(errno)); return -1; } else { - debug3("sockread EAGAIN: %d %d (%s)", slist[i].sock, errno, - strerror(errno)); + debug2("net: EAGAIN socket %d error %s", slist[i].sock, strerror(errno)); continue; /* EAGAIN */ } } From 98b8d1c78a87f2a02a3085da490c0180a4898b5c Mon Sep 17 00:00:00 2001 From: Michael Ortmann Date: Sat, 13 Jun 2026 02:09:59 +0200 Subject: [PATCH 2/4] Fix log --- src/net.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/net.c b/src/net.c index 0fc819cbd..0ed59b687 100644 --- a/src/net.c +++ b/src/net.c @@ -1024,10 +1024,16 @@ int sockread(char *s, int *len, sock_list *slist, int slistmax, int tclonly) * otherwise it will connect. */ *len = slist[i].sock; slist[i].flags &= ~SOCK_CONNECT; - debug2("net: eof!(read) socket %d error %s", slist[i].sock, strerror(errno)); + if (x < 0) + debug2("net: eof!(read) socket %d error %s", slist[i].sock, strerror(errno)); + else + debug1("net: eof!(read) socket %d", slist[i].sock); return -1; } else { - debug2("net: EAGAIN socket %d error %s", slist[i].sock, strerror(errno)); + if (x < 0) + debug2("net: EAGAIN socket %d error %s", slist[i].sock, strerror(errno)); + else + debug1("net: EAGAIN socket %d", slist[i].sock); continue; /* EAGAIN */ } } From 156b2bd82f77fbc3d410f500614626b52139dc73 Mon Sep 17 00:00:00 2001 From: Michael Ortmann Date: Sat, 13 Jun 2026 05:40:07 +0200 Subject: [PATCH 3/4] Fix connect, detect eof after select() before read() --- src/net.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/net.c b/src/net.c index 0ed59b687..538ce0d12 100644 --- a/src/net.c +++ b/src/net.c @@ -570,7 +570,7 @@ int connect_nonblock(int s, sockname_t *addr, int check_tcl_event_ident) { return -4; } if (res != 0) { - debug1("net: getsockopt error %d", res); + debug2("net: getsockopt() socket %i error %s", s, strerror(res)); return -1; } return s; /* async success! */ @@ -914,6 +914,8 @@ int sockread(char *s, int *len, sock_list *slist, int slistmax, int tclonly) struct dns_thread_node *dtn, *dtn_prev; void *res; #endif + int res2; + socklen_t res2_len; maxfd_r = preparefdset(&fdr, slist, slistmax, tclonly, TCL_READABLE); #ifdef EGG_TDNS @@ -970,6 +972,14 @@ int sockread(char *s, int *len, sock_list *slist, int slistmax, int tclonly) #else else if (!(slist[i].flags & SOCK_STRONGCONN)) { #endif + res2_len = sizeof(res2); + getsockopt(slist[i].sock, SOL_SOCKET, SO_ERROR, &res2, &res2_len); + if (res2 > 0 && res2 != EINPROGRESS) { + debug2("net: connect! sock %d error %s", slist[i].sock, strerror(res2)); + s[0] = 0; + *len = slist[i].sock; + return -1; + } debug1("net: connect! sock %d", slist[i].sock); s[0] = 0; *len = 0; From a552544fcb322bd1e8e11b75d8f84d7fa276686d Mon Sep 17 00:00:00 2001 From: Michael Ortmann Date: Sat, 13 Jun 2026 15:37:29 +0200 Subject: [PATCH 4/4] style --- src/net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net.c b/src/net.c index 538ce0d12..6a23f2dd0 100644 --- a/src/net.c +++ b/src/net.c @@ -974,7 +974,7 @@ int sockread(char *s, int *len, sock_list *slist, int slistmax, int tclonly) #endif res2_len = sizeof(res2); getsockopt(slist[i].sock, SOL_SOCKET, SO_ERROR, &res2, &res2_len); - if (res2 > 0 && res2 != EINPROGRESS) { + if ((res2 > 0) && (res2 != EINPROGRESS)) { debug2("net: connect! sock %d error %s", slist[i].sock, strerror(res2)); s[0] = 0; *len = slist[i].sock;