From 6d82d171b7fcbf4223cb938894684b7efeda0a58 Mon Sep 17 00:00:00 2001 From: Tom Hirst Date: Thu, 9 Oct 2014 11:30:02 +0100 Subject: [PATCH] if_nametoindex being called with empty string Calling if_nametoindex with an empty string will always return 0, but on ARM linux platforms this call seems to be very expensive (~30ms), adding a large overhead to calls such as QUdpSocket::writeDatagram() Change-Id: I05e644ec284ebcc5688cc108d98f7c36ec12fe90 --- src/network/socket/qnativesocketengine_unix.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index 65244ce..46d703f 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -383,7 +383,7 @@ bool QNativeSocketEnginePrivate::nativeConnect(const QHostAddress &addr, quint16 bool ok; sockAddrIPv6.sin6_scope_id = scopeid.toInt(&ok); #ifndef QT_NO_IPV6IFNAME - if (!ok) + if (!ok && !scopeid.isEmpty()) sockAddrIPv6.sin6_scope_id = ::if_nametoindex(scopeid.toLatin1()); #endif Q_IPV6ADDR ip6 = addr.toIPv6Address(); @@ -907,7 +907,7 @@ qint64 QNativeSocketEnginePrivate::nativeSendDatagram(const char *data, qint64 l bool ok; sockAddrIPv6.sin6_scope_id = scopeid.toInt(&ok); #ifndef QT_NO_IPV6IFNAME - if (!ok) + if (!ok && !scopeid.isEmpty()) sockAddrIPv6.sin6_scope_id = ::if_nametoindex(scopeid.toLatin1()); #endif sockAddrSize = sizeof(sockAddrIPv6); -- 1.8.1.4