From 7a6d93159b7bffef8be6b82112cf1616d00bd4c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Jos=C3=A9=20Arboleda?= Date: Fri, 30 Jan 2026 20:16:38 -0500 Subject: [PATCH] fixup: remove win, return ENOSYS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Juan José Arboleda --- CMakeLists.txt | 3 +-- src/uv-common.c | 45 ++++++++---------------------------------- test/test-socket-tos.c | 20 ++++++++++++++++++- 3 files changed, 28 insertions(+), 40 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a912fc2f9..e5e27ae15 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -196,8 +196,7 @@ if(WIN32) ws2_32 dbghelp ole32 - shell32 - qwave) + shell32) list(APPEND uv_sources src/win/async.c src/win/core.c diff --git a/src/uv-common.c b/src/uv-common.c index 622cb67fe..892423bc8 100644 --- a/src/uv-common.c +++ b/src/uv-common.c @@ -32,8 +32,6 @@ #if defined(_WIN32) # include /* malloc */ -# include -# include #else # include /* if_nametoindex */ # include /* AF_UNIX, sockaddr_un */ @@ -1075,6 +1073,10 @@ int uv_socket_get_tos(const uv_handle_t* handle, int* tos) { socklen_t optlen; struct sockaddr_storage storage; +#if defined(_WIN32) + return UV_ENOSYS; +#endif + addrlen = sizeof(storage); tos_ = 0; optlen = sizeof(tos_); @@ -1114,11 +1116,7 @@ int uv_socket_get_tos(const uv_handle_t* handle, int* tos) { return UV_EAFNOSUPPORT; } -#if defined(_WIN32) - r = getsockopt(fd, level, option, (char*)&tos_, &optlen); -#else r = getsockopt(fd, level, option, &tos_, &optlen); -#endif if (r) return r; @@ -1135,6 +1133,10 @@ int uv_socket_set_tos(const uv_handle_t* handle, int tos) { int level; int option; +#if defined(_WIN32) + return UV_ENOSYS; +#endif + addrlen = sizeof(storage); if (tos < 0 || tos > 255) @@ -1171,37 +1173,6 @@ int uv_socket_set_tos(const uv_handle_t* handle, int tos) { return UV_EAFNOSUPPORT; } -#ifndef _WIN32 r = setsockopt(fd, level, option, &tos, sizeof(tos)); return UV__ERR(r); -#else - HANDLE qosHandle = NULL; - QOS_VERSION version = {1, 0}; - QOS_FLOWID flowId = 0; - DWORD dscpValue = (DWORD)tos; - SOCKET socket = (SOCKET)fd; - - /* NOTE: I'm using setsockopt here to set the TOS value directly on the socket as UNIX. - * I'm not too worried about this one, let's use the QOS API as a backup plan. - */ - setsockopt(fd, level, option, (char*)&tos, sizeof(tos)); - - if (storage.ss_family == AF_UNSPEC) { - /* Can't set DSCP on an unspecified address */ - return UV_ENOTCONN; - } - - /* Do the same thing using QOS APIs just to be sure */ - if (QOSCreateHandle(&version, &qosHandle)) { - if(QOSAddSocketToFlow(qosHandle, socket, NULL, QOSTrafficTypeBestEffort, 0, &flowId)) { - QOSSetFlow(qosHandle, flowId, QOSSetOutgoingDSCPValue, sizeof(dscpValue), &dscpValue, 0, NULL); - } else { - int err = WSAGetLastError(); - printf("QOSAddSocketToFlow failed with error: %d\n", err); - } - QOSCloseHandle(qosHandle); - return 0; - } -#endif - return 0; } diff --git a/test/test-socket-tos.c b/test/test-socket-tos.c index 2d5a5304a..c3de8fdec 100644 --- a/test/test-socket-tos.c +++ b/test/test-socket-tos.c @@ -19,8 +19,8 @@ * IN THE SOFTWARE. */ -#include "task.h" #include "uv.h" +#include "task.h" static void setup_tcp(uv_loop_t* loop, uv_tcp_t* tcp, const char* ip, int is_ip6) { @@ -86,6 +86,9 @@ static void check_tos_fail(uv_handle_t* handle, int tos) { } TEST_IMPL(tcp_socket_set_get_tos) { +#if defined(_WIN32) + RETURN_SKIP("Windows does not support setting TOS"); +#endif uv_tcp_t tcp; setup_tcp(uv_default_loop(), &tcp, "0.0.0.0", 0); @@ -106,6 +109,9 @@ TEST_IMPL(tcp_socket_set_get_tos) { } TEST_IMPL(tcp6_socket_set_get_tos) { +#if defined(_WIN32) + RETURN_SKIP("Windows does not support setting TOS"); +#endif uv_tcp_t tcp; setup_tcp(uv_default_loop(), &tcp, "::1", 1); @@ -122,6 +128,9 @@ TEST_IMPL(tcp6_socket_set_get_tos) { } TEST_IMPL(udp_socket_set_get_tos) { +#if defined(_WIN32) + RETURN_SKIP("Windows does not support setting TOS"); +#endif uv_udp_t udp; setup_udp(uv_default_loop(), &udp, "0.0.0.0", 0); @@ -141,6 +150,9 @@ TEST_IMPL(udp_socket_set_get_tos) { } TEST_IMPL(udp6_socket_set_get_tos) { +#if defined(_WIN32) + RETURN_SKIP("Windows does not support setting TOS"); +#endif uv_udp_t udp; setup_udp(uv_default_loop(), &udp, "::1", 1); @@ -157,6 +169,9 @@ TEST_IMPL(udp6_socket_set_get_tos) { } TEST_IMPL(socket_tos_invalid_handle) { +#if defined(_WIN32) + RETURN_SKIP("Windows does not support setting TOS"); +#endif uv_timer_t timer; int r; int tos; @@ -181,6 +196,9 @@ TEST_IMPL(socket_tos_invalid_handle) { } TEST_IMPL(socket_tos_unbound_tcp) { +#if defined(_WIN32) + RETURN_SKIP("Windows does not support setting TOS on UDP sockets"); +#endif uv_tcp_t tcp; int r; int tos;