summaryrefslogtreecommitdiffstats
path: root/src/network/socket/qnativesocketengine_unix.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2014-12-24 17:01:52 -0200
committerThiago Macieira <thiago.macieira@intel.com>2015-02-15 01:26:28 +0000
commitd866f6e8861647c45f438bc5b21905dacee41f8e (patch)
treefda6c73cc1164ff2cac9bccc02657cf2990347ff /src/network/socket/qnativesocketengine_unix.cpp
parent0fa7374f1dc433b6b8955cb14dabb22c10f50854 (diff)
Save two system calls for setting a socket non-blocking on Linux
Linux's socket(2) system call can take SOCK_NONBLOCK and let us avoid the extra two fcntl(2) to change the setting after it's created. Change-Id: Ie0d7a2d51acc21acd850cbee6d0f76e27b1ae859 Reviewed-by: Richard J. Moore <rich@kde.org>
Diffstat (limited to 'src/network/socket/qnativesocketengine_unix.cpp')
-rw-r--r--src/network/socket/qnativesocketengine_unix.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp
index eed1b70025..a7534a2f3f 100644
--- a/src/network/socket/qnativesocketengine_unix.cpp
+++ b/src/network/socket/qnativesocketengine_unix.cpp
@@ -138,10 +138,10 @@ bool QNativeSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType soc
int protocol = (socketProtocol == QAbstractSocket::IPv6Protocol || socketProtocol == QAbstractSocket::AnyIPProtocol) ? AF_INET6 : AF_INET;
int type = (socketType == QAbstractSocket::UdpSocket) ? SOCK_DGRAM : SOCK_STREAM;
- int socket = qt_safe_socket(protocol, type, 0);
+ int socket = qt_safe_socket(protocol, type, 0, O_NONBLOCK);
if (socket < 0 && socketProtocol == QAbstractSocket::AnyIPProtocol && errno == EAFNOSUPPORT) {
protocol = AF_INET;
- socket = qt_safe_socket(protocol, type, 0);
+ socket = qt_safe_socket(protocol, type, 0, O_NONBLOCK);
socketProtocol = QAbstractSocket::IPv4Protocol;
}