summaryrefslogtreecommitdiffstats
path: root/src/network/socket/qnativesocketengine_unix.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Add TCP Keepalive options to QAbstractSocketMate Barany17 hours1-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TCP Keepalive is turned on for QNAM but it is using the default system values. On Linux this means that it takes 131 minutes to tear down the connection. This can be customized with the values of TCP_KEEPIDLE - how long do we wait before we send probes TCP_KEEPINTVL - the time interval between two probes TCP_KEEPCNT - the number of probes sent So extend Qabstractsocket with the following socketoptions: KeepAliveIdleOption (TCP_KEEPIDLE) KeepAliveIntervalOption (TCP_KEEPINTVL) KeepAliveCountOption (TCP_KEEPCNT) Not all platforms provide the same support for these parameters. What we know: On Linux, all of the above is supported. On Windows, these are supported since Windows 10, 1709. On Mac all of the above is supported but TCP_KEEPIDLE is called TCP_KEEPALIVE. On QNX 7.1 only TCP_KEEPIDLE is supported and it is called as TCP_KEEPALIVE. On QNX 8.0 all of the above is supported and TCP_KEEPIDLE is called TCP_KEEPIDLE. MinGW also supports all of the above from version 12, but it seems that we have an older version in the CI so we need some ifdefs. VxWorks also supports TCP_KEEPIDLE, TCP_KEEPCNT and TCP_KEEPINTVL. [ChangeLog][QtNetwork][QAbstractSocket] Added new socketoptions to QAbstractSocket: KeepAliveIdleOption, KeepAliveIntervalOption and KeepAliveCountOption. Task-number: QTBUG-136625 Change-Id: I89d1788a19719da10ce740b52b2a6570680e0f5d Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QNativeSocketEngine/VxWorks: also handle ENOTSUPKarim Pinter17 hours1-1/+3
| | | | | | | | | | VxWorks doesn't return standard error types, so there is a need to extend the error handling for this OS. Task-number: QTBUG-138759 Pick-to: 6.8 6.10 Change-Id: I01de0f759c732ae840711949c769a4710aad306f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QNativeSocketEngine/Unix: detect sockaddr_dl with AF_LINKThiago Macieira2025-10-211-3/+3
| | | | | | | | | | | | Instead of by proxy trying to guess that BSD systems have it and others don't. That's an incorrect assumption because QNX has this and IP_RECVIF, but isn't marked a Q_OS_BSD4. FreeBSD says sockaddr_dl should have .sdl_family = AF_LINK: http://fxr.watson.org/fxr/source/net/if_dl.h Change-Id: Ibe2777515c0f71285783fffd5c0094f622de34a9 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QNativeSocketEngine/Unix: implement IP_RECVIF in setOption()Thiago Macieira2025-10-211-4/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This amends and complements abe269bb72233b360bccbc8f54d3f13e8dc10b5a, which added QNativeSocketEngine::ReceivePacketInformation and actually did implement the heretofore-dead code to handle the IP_RECVIF ancilary data in nativeReceiveDatagram(), but we never asked the OS for the information via setsockopt(). Similar to what e9778dfe6ead0c4d704570816a56aead084a0263 did for Windows. Tested on FreeBSD. dtruss says: socket(PF_INET,SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK,0) = 7 (0x7) setsockopt(7,SOL_SOCKET,SO_BROADCAST,0xb1cf40aece4,4) = 0 (0x0) setsockopt(7,IPPROTO_IP,IP_RECVDSTADDR,0xb1cf40aece4,4) = 0 (0x0) setsockopt(7,IPPROTO_IP,IP_RECVIF,0xb1cf40aece4,4) = 0 (0x0) setsockopt(7,IPPROTO_IP,IP_RECVTTL,0xb1cf40aece4,4) = 0 (0x0) bind(7,{ AF_INET 127.0.0.1:0 },16) = 0 (0x0) ... ppoll({ 7/POLLIN },1,{ 8.999999439 },0x0) = 1 (0x1) recvfrom(7,"@",1,MSG_PEEK,NULL,0x0) = 1 (0x1) recvmsg(7,{{ AF_INET 127.0.0.1:55621 },16,[{"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"...,1200}],1, { {level=IPPROTO_IP,type=IP_RECVDSTADDR,data={0x7f,0x00,0x00,0x01}}, {level=IPPROTO_IP,type=IP_RECVTTL,data={0x40}}, {level=IPPROTO_IP,type=IP_RECVIF,data={0x38,0x12,0x02,0x00,0x18,0x03,0x00,0x00,0x6c,0x6f,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}} },120,0},0) = 600 (0x258) lldb decodes the sockaddr_dl as: (lldb) p *sdl (sockaddr_dl) { sdl_len = '8' sdl_family = '\x12' sdl_index = 2 sdl_type = '\x18' sdl_nlen = '\x03' sdl_alen = '\0' sdl_slen = '\0' sdl_data = "lo0" } And interface index 2 is lo0: lo0: flags=1008049<UP,LOOPBACK,RUNNING,MULTICAST,LOWER_UP> metric 0 mtu 16384 options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6> inet 127.0.0.1 netmask 0xff000000 inet6 ::1 prefixlen 128 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2 groups: lo nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL> Change-Id: I37b88bfce40421117d99fffd1110eced5d102430 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QNativeSocketEnginePrivate::setOption: simplify ugly perror() handlingThiago Macieira2025-10-171-13/+10
| | | | | | | | | | | With a macro. Drive-by clean up the VxWorks implementation of NonBlockingSocketOption, as we know v == 1 on input. Pick-to: 6.10 6.9 6.8 Change-Id: I917f5f39ded2fa338803fffd91002fca28d7faaa Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Teach QNativeSocketEnginePrivate::fetchConnectionParameters() about ↵Gleb Popov2025-10-101-8/+15
| | | | | | | | SOCK_SEQPACKET Pick-to: 6.10 Change-Id: I4136ef3b4c198e3bd155884bde53171bd34959e4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Allow binding a socket to a specific QNetworkInterfaceIvan Solovev2025-10-091-1/+25
| | | | | | | | | | | | | | | | | | | | | For now, via a private API. Provide a new socket engine option - BindInterfaceIndex, and use it if a valid interface is passed to QAbstractSocketPrivate::bind(). Note that this feature is not fully functional on macOS: both SO_BINDTODEVICE and IP{V6}_BOUND_IF only work for limiting outgoing datagrams. The patch uses IP{V6}_BOUND_IF, because it allows to avoid number -> string -> number conversion. As of now, extra filtering of incoming data should be done on the user side. Task-number: QTBUG-80704 Task-number: QTBUG-139697 Pick-to: 6.10 6.8 Change-Id: Ic207908313d9d25f96c23ecc363181ff0ae8232a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QNativeSocketEngine: enable dual-stack as early as possibleIvan Solovev2025-10-091-0/+14
| | | | | | | | | | | | | | | | | | | | Try to disable the IPV6_V6ONLY socket option right after creating the socket. This is important, because it can affect how setting other options works. For example, on Windows we could not properly set the ReceivePacketInformation option before calling bind()/connectToHost(). If we're actually binding/connecting to an IPv6 address, then the pre-existing code in nativeBind()/nativeConnect() would take care of adjusting the option again. Task-number: QTBUG-80704 Task-number: QTBUG-139697 Pick-to: 6.10 6.8 Change-Id: I6d504d354f63f441c90df21f933fd800fafa655f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* CRA[network/socket]: Mark the rest significantMårten Nordheim2025-07-281-0/+1
| | | | | | | | | The rest was handled separately. Fixes: QTBUG-135585 Pick-to: 6.10 6.9 6.8 Change-Id: I7fe912dc0742b4eedcdd001387de7f3fb85b7fe2 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* VxWorks-specific implementation of nativePendingDatagramSize()Jacek Poplawski2025-07-071-0/+6
| | | | | | | | | | | | | Previously, VxWorks was using the generic fallback code path, which attempts to peek UDP datagrams using recvmsg() and checks for MSG_TRUNC to infer size. However, on VxWorks, MSG_TRUNC is not reliably reported, causing incorrect or truncated datagram size detection, and in some cases infinite buffer growth or bad_alloc crashes. Task-number: QTBUG-130078 Pick-to: 6.10 6.9 6.8 6.5 Change-Id: I1ee3704a64c3579142b74198bbc55575355617bb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QNativeSocketEngine: React on POLLHUP too when selecting for writingGleb Popov2025-06-121-1/+1
| | | | | | | | FreeBSD may return a single POLLHUP revent not coupled with any of POLLOUT nor POLLERR. This causes a busy-loop, so put POLLHUP into write_flags. Change-Id: Ief62138eeb6de8e2caf1d6937507bfd828adfb81 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* wasm: fix QTcpSocket error code when url doesn't existLorn Potter2025-03-181-0/+1
| | | | | | | | | | | | ::connect on wasm seems to be returning 0 in the instance that the server url does not exist. So we ignore that and look at errno, which returns ENOENT which makes no sense here. Fixes: QTBUG-132191 Pick-to: 6.9 Change-Id: I2ff6642dd836324e1af6c288c53880de028ce158 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Fix -Wimplicit-fallthrough for clangTim Blechmann2024-03-011-0/+1
| | | | | | | | | | | | | | | | | | | Clang's `-Wimplicit-fallthrough` warnings are a little stricter than gcc's interpretation: switch (i) { case 0: foo(); case 4: break; } While gcc accepts the implicit fallthrough, if the following statement is a trivial `break`, clang will warn about it. Pick-to: 6.7 Change-Id: I38e0817f1bc034fbb552aeac21de1516edcbcbb0 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Handle EWOULDBLOCK the same way as EAGAIN when writing to sockets on UnixŁukasz Matysiak2024-01-281-0/+3
| | | | | | | | | | | | | | | On most platforms EWOULDBLOCK is defined to be equal to EAGAIN. However on some platforms (like VxWorks) it is not the case. Because of that, error returned from ::write is not handled properly on such platform. Since C++ does not allow duplicate switch labels, check if EWOULDBLOCK and EAGAIN have different values before adding EWOULDBLOCK to the switch statement. Task-number: QTBUG-115777 Pick-to: 6.7 Change-Id: I659cb946f239733f5c57b2000fb4e3d296ed9153 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Rename EINTR_LOOP -> QT_EINTR_LOOPMarc Mutz2023-11-301-2/+2
| | | | | | | | | | | | | | | This non-namespaced macro was defined in a header, and while that header is private, we shouldn't define non-namespaced macros in our headers. The macro also clashed with one of the same name defined in forkfd.c, which broke unity-builds including the forkfd_qt.cpp TU. This rename fixes that, too, so we can now remove forkfd_qt.cpp from NO_UNITY_BUILD_SOURCES. Pick-to: 6.6 6.5 Change-Id: Ic4bb4e4d7a632ca87905e48913db788a7c202314 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* qcore_unix: port qt_safe_poll to QDeadlineTimerAhmad Samir2023-10-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | Remove qt_poll_msecs() since the "forever" state can be simply expressed with a QDeadlineTimer::Forever arg, instead of passing a nullptr timespec, and the negative timeouts treated as "run forever" is also encapsulated by QDealineTimer. Use the QDealineTimer(qint64) constructor in the call sites where the timeout could be negative, so that it creates a Forever timer (the QDeadlineTimer(chrono::duration) constructor uses setRemainingTime(duration) which handles negative timeouts by creating expired timers). Remove qt_gettime() (and do_gettime()). Drive-by changes: - Fix a narrowing conversion warning, qt_make_pollfd() takes an int - Remove an unused include Change-Id: I096319af5e191e28c3d39295fb1aafe9d69841e6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QAbstractSocketEngine: port to QDeadlineTimerAhmad Samir2023-10-071-9/+13
| | | | | | | | | | | | | | | | qnativesocketengine_win.cpp: don't check if timeout is < 0, because remainingTimeAsDuration() doesn't return negative values. All the changes done in one go, not function by function, as that causes the least churn. You can think of them as a couple of very similar changes repeated various times. Drive-by change: replace `forever {` with `for (;;)` Task-number: QTBUG-113518 Change-Id: Ie9f20031bf0d4ff19e5b2da5034822ba61f9cbc3 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QNativeSocketEngine: fix build with FreeBSD: sockaddr_dl wasn't declaredThiago Macieira2023-09-261-0/+3
| | | | | | | | | | | This partially reverts fcb548878bfae3db34d482f3ad97074aca76b410. qnativesocketengine_unix.cpp:872:40: error: unknown type name 'sockaddr_dl'; did you mean 'sockaddr_in'? Pick-to: 6.6 Change-Id: Ifeb6206a9fa04424964bfffd178844096ee7741b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* CMake/Network: limit the testing for some network iface featuresThiago Macieira2023-08-301-13/+0
| | | | | | | | | | | | | | | | | | | | | These features are now only used for qnetworkinterface_unix.cpp, so they aren't needed for Windows or for Linux with AF_NETLINK support. This commit removes the last couple of placess outside of that file where they were used (the qnativesocketengine_unix.cpp code looked stale anyway). These tests cost us approximately 1300 ms during CMake time. This commit does not change that because the tests are checked even if the condition has already been forced OFF by previous conditions. [ChangeLog][Build system] The QT_NO_GETIFADDRS and QT_NO_IPV6IFNAME macros are deprecated. On a standard Linux build, they will be defined to 1, even if the system does support getifaddrs() and ifnametoindex(). Task-number: QTBUG-107248 Task-number: QTBUG-115705 Change-Id: Ifbf974a4d10745b099b1fffd17775822a1a6e55f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Network: Fix IFF_UP conflict on Linux with unity buildsMårten Nordheim2023-05-261-0/+4
| | | | | | | | | | | I cannot repro this myself, but from the bug report it seems to be defined in two headers, so we should consistently use the same one. Fixes: QTBUG-113787 Pick-to: 6.5 Change-Id: I9f1cc51e379c33dbbf659946340a5207aaeb448a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QtNetwork: Split out QNativeSocketEnginePrivateFriedemann Kleint2023-02-021-1/+1
| | | | | | | | | | | The aim is to have fewer files including <windows.h>. Pick-to: 6.5 Task-number: QTBUG-109394 Change-Id: Id9cc08f54b5daf6d7e317fad27036dc2efaacbb8 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Port from container.count()/length() to size()Marc Mutz2022-10-041-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Make sockets' accept() methods return qintptrMårten Nordheim2022-08-241-2/+2
| | | | | | | | | | | Not necessarily relevant outside windows, where the socket descriptor is SOCKET (= unsigned 64-bit). Also follow their recommendation to not compare to -1, but rather to INVALID_SOCKET. Pick-to: 6.4 6.3 6.2 Change-Id: I0cfa4dfd9e147469132e2e72de22b30eab01e15c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* wasm: add support for blocking socketsMorten Johan Sørvig2022-06-021-0/+25
| | | | | | | | | | | | | | | | | | | | | Add support for blocking sockets on secondary threads and on the main thread with asyncify. This extends the support for websockify tunneled TCP sockets, which was previously limited to async sockets on the main thread. Blocking sockets support is implemented by emulating select() on top of emscripten's socket notification support. This is requires synchronization between the blockee threads and the main thread, since we get socket notification callbacks on the main thread. The synchronized state is held in g_socketState where the main thread registers socket readiness state and blocking threads register themselves. Blocking using asyncify on the main thread is similar to blocking on a secondary thread, with the exception that the main thread suspends with qt_asyncify_suspend() instead of waiting on a wait condition. Change-Id: Idb5a493644e1e6634057dc2f64f2e99e82e3c01e Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Use SPDX license identifiersLucie Gérard2022-05-161-39/+3
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Fix getsockopt option_value initial initializationPasi Petäjäjärvi2022-02-241-2/+3
| | | | | | | | | | | | | On some platforms, some of the options we're getting the value for may be a single byte, so attempting to read the full int produces garbage. Found with IP_MULTICAST_TTL and IP_MULTICAST_LOOP on QNX. See: https://www.qnx.com/developers/docs/7.1/index.html#com.qnx.doc.neutrino.lib_ref/topic/g/getsockopt.html#getsockopt__IP_MULTICAST_TTL Pick-to: 5.15 6.2 6.3 Change-Id: Id9f7f249c6c4be0c3f94c5904d402b4ec4e17b59 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Consolidate debug string generationAlex Trotsenko2021-05-311-42/+7
| | | | | | | | | | | | | | Several QIODevice subclasses use the qt_prettyDebug() function to get a printable representation of the buffer data for debug output. Rather than having this feature statically implemented in each respective file, this patch introduces a generic function in the QtDebugUtils namespace. Accordingly, some inaccuracies in the use-cases have been corrected. Change-Id: I1a8465cab08c8acf5fdcdba5085182511b1cbb7b Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Add Solaris support in cmake buildNiclas Rosenvik2021-04-211-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | Add SOLARIS cmake platform definition. Add settings for QT_DEFAULT_MKSPEC so that qplatformdefs.h can be found. Solaris has its gssapi symbols in libgss. Solaris supports @ORIGIN. Solaris ld does not support --dynamic-list needed for reduce relocations. Make solaris fail the reduce relocation test. getauxval is specific to GNU libc and some other libc implementations on Linux but sys/auxv.h is not. The bootstrap uses sys/aux.h as the only indication for getauxval. This breaks builds on Solaris, so only make sys/auxv.h an indicator for getauxval on linux or glibc based systems. Solaris uses X11 so add it to the X11_SUPPORTED list. Solaris network libraries for sockets etc are in socket and nsl. ifreq does not have a member ifr_ifindex on Solaris, it uses ifr_index. Add test to check if ifr_index is a member of ifreq. The first struct in the in_addr union on solaris is defined as four uint8_t, therefore four arguments are needed for its initializer list. Change-Id: Ieed4c1bbac8559a7ae1db9c4e1e91f609f150270 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Remove redundant invalid socket checkEdward Welbourne2021-02-181-5/+3
| | | | | | | | | It happens after the same socket check has lead to an early return. Prompted by a PVS-studio article. Change-Id: I63b42abed9102df73d29e6ff8a89a475751d4b91 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Port Q_STATIC_ASSERT(_X) to static_assertGiuseppe D'Angelo2020-06-191-1/+1
| | | | | | | | | | | | | | | | | There is no reason for keep using our macro now that we have C++17. The macro itself is left in for the moment being, as well as its detection logic, because it's needed for C code (not everything supports C11 yet). A few more cleanups will arrive in the next few patches. Note that this is a mere search/replace; some places were using double braces to work around the presence of commas in a macro, no attempt has been done to fix those. tst_qglobal had just some minor changes to keep testing the macro. Change-Id: I1c1c397d9f3e63db3338842bf350c9069ea57639 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Tidy nullptr usageAllan Sandfeld Jensen2019-12-061-3/+3
| | | | | | | | | | | Move away from using 0 as pointer literal. Done using clang-tidy. This is not complete as run-clang-tidy can't handle all of qtbase in one go. Change-Id: I1076a21f32aac0dab078af6f175f7508145eece0 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QNativeSocketEngine: disable sign-compare warning-turned-error on ClangMarc Mutz2019-07-131-0/+3
| | | | | | | | | | | | | | | | | | On the WASM platform, the macro CMDG_NEXTHDR, which is not under our control, emits a warning about comparing ulong and long with each other, which -Werror turns into an error: qnativesocketengine_unix.cpp:1004:24: error: comparison of integers of different signs: 'unsigned long' and 'long' [-Werror,-Wsign-compare] cmsgptr = CMSG_NXTHDR(&msg, cmsgptr)) { ^~~~~~~~~~~~~~~~~~~~~~~~~~ emsdk/emscripten/1.38.30/system/include/libc/sys/socket.h:286:44: note: expanded from macro 'CMSG_NXTHDR' __CMSG_LEN(cmsg) + sizeof(struct cmsghdr) >= __MHDR_END(mhdr) - (unsigned char *)(cmsg) \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fix by locally disabling the warning. Change-Id: Ia2ed4318b2ef679b84ac8544835d1e383568ccac Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use timeout error for TCP timeouts on unixSven Erdem2018-11-111-5/+9
| | | | | | | | | | | | When a TCP connection timed out a QAbstractSocket::NetworkError was set. To enable a more precise error handling for timeouts QAbstractSocket::SocketTimeoutError is now set instead. Separated ETIMEDOUT from other errors in nativeRead() and take over responsibility for setting the error, which was previously handled by read(). Change-Id: Iccd45bdbb3d944cd160ae50c257d3256e05b1ae5 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: David Faure <david.faure@kdab.com>
* QAbstractSocket: Add socketOption for the Path MTUThiago Macieira2017-11-141-0/+30
| | | | | | | | | | | This allow retrieving the value of the known PMTU for the current socket. This works on Linux (IPv6 and IPv4) and FreeBSD (IPv6 only) -- the other OSes don't have the necessary API. Note: do we need add IP_MTU_DISCOVER? Change-Id: I6e9274c1e7444ad48c81fffd14dcaf97a18ce335 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QNativeSocketEngine: Simplify nativeHasPendingDatagrams()Thiago Macieira2017-09-131-11/+3
| | | | | | | We don't need the sockaddr structure. Change-Id: I6e9274c1e7444ad48c81fffd14da826387d72f83 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QNativeSocketEngine: reduce memory usage in nativePendingDatagramSize()Thiago Macieira2017-09-131-5/+25
| | | | | | | | | | | | | | | | The Windows implementation had the right idea: by using a chunked read, we can tell the OS to reuse the same buffer over and over, so we don't need to grow a buffer to the size of the datagram when peeking. This commit implements that strategy on Unix and changes both implementations to start at 1500 bytes instead of 8192 (1500 is more than enough for almost all datagrams we're going to receive). Let's also not use a static buffer, but a stack-based one. No need to dedicate 1500 (or, worse, 8192) bytes for something that is only seldom called. Change-Id: I320d9d2f42284a69a4cbfffd14dd92a6775bf28b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QUdpSocket: use faster ways to get datagram size on Linux and macOSThiago Macieira2017-08-271-2/+15
| | | | | | | | | | With MSG_TRUNC on Linux, recv/recvfrom/recvmsg will return the full size of the datagram, even if it won't fit the buffer you passed. On Darwin, we have a getsockopt() option to get that value. Change-Id: I6e9274c1e7444ad48c81fffd14da7d5b93815f90 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-04-071-1/+4
|\ | | | | | | | | | | | | | | | | | | Conflicts: mkspecs/linux-icc/qmake.conf mkspecs/macx-icc/qmake.conf mkspecs/win32-icc/qmake.conf src/gui/painting/qgrayraster.c Change-Id: Ib08c45ea3215be05f986ecb3e1f4b37d209aa775
| * Fix GCC warning about dereferencing type-punned pointersThiago Macieira2017-04-061-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | GCC is wrong. Type-punning is when you read something of a given type as something else. We're not doing that, as it's only read as integer. qnativesocketengine_unix.cpp:1011:79: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing] Too bad my plan for a good C++ solution was foiled by glibc developers. Change-Id: I27b55fdf514247549455fffd14b1a27667745e94 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
| * Fix build without features.networkinterfaceTasuku Suzuki2017-04-041-0/+2
| | | | | | | | | | Change-Id: I9fd2a7ec402a1d2d99e30f08554d86f18c6424ff Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* | Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-03-021-4/+10
|\| | | | | | | Change-Id: I84097f8e7b3b2128028bd7693c913d6968b82bfe
| * Fix multicastMembershipHelper to not assume addresses are IPv4Edward Welbourne2017-02-221-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Make it iterate the addresses available looking for an IPv4 address, when that's what it needs, instead of just assuming the first entry in the list (when non-empty) is IPv4. Based on a suggestion by Dmitry Pankratov. Task-number: QTBUG-27641 Change-Id: I1920f68ade44a996ea5c2ed691a87ff3e686f35a Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Join two else/if lines that were left splitEdward Welbourne2017-02-211-2/+1
|/ | | | | | | Probably after-effects of some #if-ery we removed long ago ... Change-Id: I8bf7a97dc5fda615bf20c37ccd9c1de0ba9194e5 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Merge remote-tracking branch 'origin/5.7' into devLiang Qi2016-08-161-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | Conflicts: qmake/doc/src/qmake-manual.qdoc src/corelib/global/qglobal.cpp src/corelib/tools/qstring.cpp src/network/socket/qabstractsocket.cpp src/network/socket/qnativesocketengine_unix.cpp src/plugins/platforms/eglfs/api/qeglfsglobal.h Change-Id: Id5dfdbd30fa996f9b4b66a0b030b7d3b8c0ef288
| * Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-08-101-1/+1
| |\ | | | | | | | | | Change-Id: I1a63523de158757964b6fb5ea026cf69a6c5ddcf
| | * QNativeSocketEngine::option(): return a correct value on invalid callAlex Trotsenko2016-08-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Instead of 'true', it should be '-1'. Change-Id: I5e8f99153da68d34b37477ef4cedbc447fba347f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | | Fix some syntax issues in SCTP implementationAlex Trotsenko2016-08-031-2/+2
| | | | | | | | | | | | | | | | | | Change-Id: I718fd060e313d544a5470fa20183db04ef89b1ca Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | | Introduce SCTP sockets supportAlex Trotsenko2016-07-271-22/+160
|/ / | | | | | | | | | | | | Add protocol-specific code and the QSctpServer, QSctpSocket classes. Change-Id: Ie9a1d87bd1fda866a2405043d1c15c12ded5a96e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.6' into 5.7Edward Welbourne2016-07-041-4/+1
|\| | | | | | | Change-Id: Ibd81cd1df4a0650d93fcb556a57be90be2e1f569
| * Replace LLINDEX macro not present on all BSDs with the codeRalf Nolden2016-07-031-4/+1
| | | | | | | | | | | | | | | | | | | | FreeBSD < 10 doesn't have the LLINDEX macro either in net/if_dl.h, so besides OpenBSD yet another condition to declare the LLINDEX macro for systems where it isn't present does make it more complicated than replacing its usage with the actual code. Change-Id: I7e8ef3e265564526e05ec3115f9fa765d399f045 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>