From c28bc5f11361960da1bc94a5ea6566ee0fc8397c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20R=C3=B6ssler?= Date: Mon, 6 Jul 2015 17:51:15 +0200 Subject: QNativeSocketEngine: fix SO_REUSEPORT problems on Linux Commit d1cd75e81af809a46fcf40cd2b39858e238a4d97 introduced the usage of the SO_REUSEPORT socket flag on Unix systems if available. However, on Linux systems this socket option behaves differently from the previously used SO_REUSEADDR socket option. This patch disables the use of the SO_REUSEPORT option to fix rebinding problems on Linux. The option was introduced to improve support on OS X and other BSDs. It is not necessary on Linux. [ChangeLog][QtNetwork][QUdpSocket] Fixed a bug that caused the QAbstractSocket::ShareAddress option not to work on Linux. Change-Id: Ice04b8b9e78400dce193e2c1d73b67e33edf8840 Reviewed-by: Richard J. Moore --- src/network/socket/qnativesocketengine_unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/network/socket') diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index 4648a3cb5a..8869d75c8b 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -337,7 +337,7 @@ bool QNativeSocketEnginePrivate::setOption(QNativeSocketEngine::SocketOption opt int n, level; convertToLevelAndOption(opt, socketProtocol, level, n); -#if defined(SO_REUSEPORT) +#if defined(SO_REUSEPORT) && !defined(Q_OS_LINUX) if (opt == QNativeSocketEngine::AddressReusable) { // on OS X, SO_REUSEADDR isn't sufficient to allow multiple binds to the // same port (which is useful for multicast UDP). SO_REUSEPORT is, but -- cgit v1.2.3