From b7037f1159d0e5ac7bfe30ffc5ea76db6500b598 Mon Sep 17 00:00:00 2001 From: Vladimir Dubrovin <3proxy@3proxy.ru> Date: Tue, 27 Oct 2026 14:40:42 +0300 Subject: [PATCH] Windows: an error set where socket errors are read errno is WSAGetLastError() on Windows, but seterrno3() set the C library's errno there: the EAGAIN of a TLS read or write wanting the socket again was not seen as one, and the error left was whatever the socket call before had set. seterrno3() sets the socket error now. socks.c assigned errno directly, which does not build on Windows. Co-Authored-By: Claude Opus 5.5 --- src/proxy.h | 3 ++- src/socks.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/proxy.h b/src/proxy.h index fa73b30..fa4cd38 100644 --- a/src/proxy.h +++ b/src/proxy.h @@ -182,7 +182,8 @@ size_t threadstacksize(int extra); #ifndef strncasecmp #define strncasecmp strnicmp #endif -#define seterrno3(x) _set_errno(x) +/* errno is WSAGetLastError() here */ +#define seterrno3(x) WSASetLastError(x) #else #define seterrno3(x) (errno = x) #endif diff --git a/src/socks.c b/src/socks.c index af3255b..54e2f1b 100644 --- a/src/socks.c +++ b/src/socks.c @@ -381,7 +381,7 @@ fflush(stderr); break; } if (!fds[0].revents) { - errno = EAGAIN; + seterrno3(EAGAIN); continue; } sasize = sizeof(param->sinsr);