From 38ee901271389fd0297225298709771d8b2dfe79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0=D0=B9=20=D0=91=D0=B5?= =?UTF-8?q?=D0=BB=D0=BE=D0=BD=D0=BE=D0=B3=D0=BE=D0=B2?= Date: Tue, 3 Feb 2026 15:37:23 +0300 Subject: [PATCH] feat(build): add conditional for SO_REUSEPORT Conditional compilation for the `SO_REUSEPORT` parameter has been added, as it may not be supported by some systems. --- src/stream/StreamNetwork.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/stream/StreamNetwork.cpp b/src/stream/StreamNetwork.cpp index 5aa2660d..03817554 100644 --- a/src/stream/StreamNetwork.cpp +++ b/src/stream/StreamNetwork.cpp @@ -107,9 +107,14 @@ namespace OpenLogReplicator { throw RuntimeException(10061, "network error, errno: " + std::to_string(errno) + ", message: " + strerror(errno) + " (6)"); constexpr int64_t opt = 1; - if (setsockopt(serverFD, SOL_SOCKET, SO_REUSEADDR | SO_REUSEPORT, &opt, sizeof(opt)) != 0) + if (setsockopt(serverFD, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) != 0) throw RuntimeException(10061, "network error, errno: " + std::to_string(errno) + ", message: " + strerror(errno) + " (7)"); +#ifdef SO_REUSEPORT + if (setsockopt(serverFD, SOL_SOCKET, SO_REUSEPORT, &opt, sizeof(opt)) != 0) + throw RuntimeException(10061, "network error, errno: " + std::to_string(errno) + ", message: " + strerror(errno) + " (21)"); +#endif + if (bind(serverFD, res->ai_addr, res->ai_addrlen) < 0) throw RuntimeException(10061, "network error, errno: " + std::to_string(errno) + ", message: " + strerror(errno) + " (8)"); if (listen(serverFD, 1) < 0)