curl/tests/server
Viktor Szakats 879a1514c3
socket: introduce SOCK_EAGAIN() and use it
To contain the logic of checking for both `EWOULDBLOCK` and/or `EAGAIN`
depending on platform/availability. Also to avoid checking for both if
they mapp to the same value, and to avoid PP guards around use.

This also ensures `EAGAIN` is consistently not checked on Windows, where
headers defined it, but `SOCKERRNO` never returns it, because curl maps
it to `WSAGetLastError()`.

If they map to the same value, checking them both in an `if` expression
trips GCC warning `-Wlogical-op` (the same way it triggers duplicate
case value error in `switch`).

Also:
- replace two `switch()` statements with the new macro.
- tests/server/sws: make two outliers use the new macro that were only
  checking for `EWOULDBLOCK` before this patch, in `connect_to()`.
- move variables to the left-side of expressions, where missing.
- rustls: use a variant of this macro that uses raw `EWOULDBLOCK`.
  Tried tracing it back to the origins, but I couldn't figure out if
  this is working as expected on all supported Windows versions in
  Rust. It seems to be using `GetLastError()`, according to
  https://docs.rs/system_error/0.2.0/system_error/, which would be
  probably incorrect.

Notes:
- it's probably a good idea to assign `SOCKERRNO` to a variable before
  passing it to this macro.

Cherry-picked from #21893

Closes #21992
2026-06-12 23:27:23 +02:00
..
.checksrc build: tidy up and dedupe strdup functions 2026-02-03 14:02:30 +01:00
.gitignore tests: always make bundles, adapt build and tests 2025-06-14 21:08:23 +02:00
CMakeLists.txt cmake: rename testbins target to tt, restore internal option 2026-03-01 00:24:47 +01:00
dnsd.c AmigaOS: fix build fallouts, re-add to CI 2026-06-12 20:27:44 +02:00
first.c tidy-up: drop stray comparisons with literal zero 2026-06-10 15:15:54 +02:00
first.h build: include curlx headers directly in src and tests 2026-03-16 12:05:39 +01:00
getpart.c tidy-up: miscellaneous 2026-06-01 22:33:57 +02:00
Makefile.am autotools: limit checksrc target to ignore non-repo test sources 2026-03-12 01:45:24 +01:00
Makefile.inc tests/server: drop unused curlx/version_win32.c 2026-03-08 18:17:11 +01:00
mqttd.c tidy-up: miscellaneous 2026-04-30 20:22:23 +02:00
resolve.c build: use more const 2026-02-02 12:32:49 +01:00
rtspd.c tidy-up: use uppercase TRUE/FALSE where missing 2026-06-09 12:52:08 +02:00
sockfilt.c tidy-up: use uppercase TRUE/FALSE where missing 2026-06-09 12:52:08 +02:00
socksd.c tidy-up: use uppercase TRUE/FALSE where missing 2026-06-09 12:52:08 +02:00
sws.c socket: introduce SOCK_EAGAIN() and use it 2026-06-12 23:27:23 +02:00
tftpd.c tidy-up: drop stray comparisons with literal zero 2026-06-10 15:15:54 +02:00
util.c build: fix -Wformat-signedness by adjusting printf masks 2026-04-16 10:32:50 +02:00