From 6e4aa6600af1c45073e564e7ab05acfa91f9bc9a Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 8 Jun 2026 02:13:20 +0200 Subject: [PATCH] add RAW macro for rustls and use it comparing to raw EWOULDBLOCK may not be working as expected on Windows. Based on this: https://doc.rust-lang.org/std/io/struct.Error.html#method.last_os_error Rust doesn't seem to be returning the socket error on Windows, but a GetLastError() which does not return EWOULDBLOCK or SOCKEWOULDBLOCK. --- lib/curl_setup.h | 2 ++ lib/vtls/rustls.c | 12 ++---------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/curl_setup.h b/lib/curl_setup.h index 1840aeff04..dde3f89e28 100644 --- a/lib/curl_setup.h +++ b/lib/curl_setup.h @@ -1139,8 +1139,10 @@ typedef unsigned int curl_bit; #if EAGAIN != SOCKEWOULDBLOCK #define SOCK_EAGAIN_EWOULDBLOCK(e) ((e) == EAGAIN || (e) == SOCKEWOULDBLOCK) +#define RAW_EAGAIN_EWOULDBLOCK(e) ((e) == EAGAIN || (e) == EWOULDBLOCK) #else #define SOCK_EAGAIN_EWOULDBLOCK(e) ((e) == EAGAIN) +#define RAW_EAGAIN_EWOULDBLOCK(e) ((e) == EAGAIN) #endif /* diff --git a/lib/vtls/rustls.c b/lib/vtls/rustls.c index 8d0285a74b..f56ea07825 100644 --- a/lib/vtls/rustls.c +++ b/lib/vtls/rustls.c @@ -160,11 +160,7 @@ static ssize_t tls_recv_more(struct Curl_cfilter *cf, io_ctx.data = data; io_error = rustls_connection_read_tls(backend->conn, read_cb, &io_ctx, &tls_bytes_read); - if(io_error == EWOULDBLOCK -#if EAGAIN != EWOULDBLOCK - || io_error == EAGAIN -#endif - ) { + if(RAW_EAGAIN_EWOULDBLOCK(io_error)) { *err = CURLE_AGAIN; return -1; } @@ -274,11 +270,7 @@ static CURLcode cr_flush_out(struct Curl_cfilter *cf, struct Curl_easy *data, while(rustls_connection_wants_write(rconn)) { io_error = rustls_connection_write_tls(rconn, write_cb, &io_ctx, &tlswritten); - if(io_error == EWOULDBLOCK -#if EAGAIN != EWOULDBLOCK - || io_error == EAGAIN -#endif - ) { + if(RAW_EAGAIN_EWOULDBLOCK(io_error)) { CURL_TRC_CF(data, cf, "cf_send: EAGAIN after %zu bytes", tlswritten_total); return CURLE_AGAIN;