From 970283c7a3e826013d30876bbd42189220eb59d6 Mon Sep 17 00:00:00 2001
From: Benny Baumann <BenBE@geshi.org>
Date: Sun, 19 Feb 2023 22:04:40 +0100
Subject: [PATCH] chg: Platform-aware handling of EAGAIN errors

---
 src/net/connection_client.hpp | 6 ++++++
 src/net/tcp_client.cpp        | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/net/connection_client.hpp b/src/net/connection_client.hpp
index a192249..91801ad 100644
--- a/src/net/connection_client.hpp
+++ b/src/net/connection_client.hpp
@@ -11,6 +11,12 @@
 #include <memory>
 #include <string>
 
+#if EAGAIN != EWOULDBLOCK
+    #define EAGAIN_WRAPPER ((errno != EAGAIN) && (errno != EWOULDBLOCK))
+#else
+    #define EAGAIN_WRAPPER (errno != EAGAIN)
+#endif
+
 namespace rmrf::net {
 
 template<class client>
diff --git a/src/net/tcp_client.cpp b/src/net/tcp_client.cpp
index 7103ed1..2c6eca0 100644
--- a/src/net/tcp_client.cpp
+++ b/src/net/tcp_client.cpp
@@ -226,7 +226,7 @@ void tcp_client::push_write_queue(::ev::io &w) {
 
     if (written >= 0) {
         buffer.advance((size_t)written);
-    } else if (errno != EAGAIN) {
+    } else if (EAGAIN_WRAPPER) {
         throw netio_exception("Failed to write latest buffer content.");
     }
 
-- 
GitLab