Fix Windows networking bugs and connection metadata mismatch
- Use closesocket() instead of close() for sockets on Windows (lib/tcp.c) - Call WSAStartup in tcp_init so outbound connections work (lib/tcp.c) - Check WSAGetLastError() instead of errno for recv/send on Windows (lib/tcp.c) - Use WSAEWOULDBLOCK instead of EINPROGRESS for non-blocking connect (lib/tcp.c) - Add NULL guard in tcp_write for stale connection handles (lib/tcp.c) - Fix ConnMetadata/TCP_Conn index mismatch in get_next_message: use event.handle.idx directly instead of searching for a free metadata slot, which could diverge when stale entries remain from failed outbound connections (lib/message.c) - Initialize num_senders to 0 and skip unused metadata in find_conn_by_target (lib/message.c) - Clear ready flag in http_server_next_request to prevent infinite loop (lib/http_server.c) - Add CRT invalid parameter handler for the HTTP proxy (src/main.c) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -272,4 +272,4 @@ int http_proxy_free(void *state)
|
||||
http_server_free(&proxy->http_server);
|
||||
free(proxy->opers);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
+13
@@ -319,6 +319,16 @@ int main(int argc, char **argv)
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
static void invalid_param_handler(const wchar_t *expr, const wchar_t *func,
|
||||
const wchar_t *file, unsigned int line, uintptr_t reserved)
|
||||
{
|
||||
(void)expr; (void)func; (void)file; (void)line; (void)reserved;
|
||||
fprintf(stderr, "[CRT] Invalid parameter in %ls (%ls:%u)\n",
|
||||
func ? func : L"?", file ? file : L"?", line);
|
||||
fflush(stderr);
|
||||
}
|
||||
#else
|
||||
#include <poll.h>
|
||||
#endif
|
||||
@@ -329,6 +339,9 @@ int main(int argc, char **argv)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
_set_invalid_parameter_handler(invalid_param_handler);
|
||||
#endif
|
||||
int ret;
|
||||
|
||||
HTTPProxy state;
|
||||
|
||||
Reference in New Issue
Block a user