summaryrefslogtreecommitdiffstats
path: root/src/network/socket
Commit message (Collapse)AuthorAgeFilesLines
* The new signal pendingConnectionAvailable is added to QTcpServerØystein Heskestad2022-06-042-6/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | The new signal pendingConnnectionAvailable is emitted after a new connection has been added to the pending connections queue. Connect to this signal and call nextPendingConnection to handle incoming connections. The existing unchanged newConnection signal is emitted after the overridable function incomingConnection is called, regardless of whether a new connection is added to the pending connections queue in the incomingConnection function or not. If a subclass that overrides incomingConnection either decides to not add all incoming connections to the pending connections queue, or to postpone adding the connection until a handshake is successfully completed, the pendingConnectionAvailable signal should be to used, because this signal directly corresponds to insertions to the pending connections queue. [ChangeLog][QtNetwork][QTcpServer] New signal pendingConnectionAvailable is emitted when a new connection is added Task-number: QTBUG-100823 Change-Id: I00c76761389065f68271553e69e6c45c393a2fa8 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* 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-1640-1528/+88
| | | | | | | | | | | | | 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>
* QtNetwork: replace remaining uses of QLatin1String by QLatin1StringViewSona Kurazyan2022-04-212-2/+2
| | | | | | | Task-number: QTBUG-98434 Change-Id: I0bb9d534ee42ccbf7d353e251ef58901a86923b4 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QtNetwork: use _L1 for for creating Latin-1 string literalsSona Kurazyan2022-04-2111-109/+118
| | | | | | Task-number: QTBUG-98434 Change-Id: Ic235b92377203f7a1429ae7fd784c4a1fa893e9f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QtNetwork: stop using QLatin1Char constructor for creating char literalsSona Kurazyan2022-04-214-10/+10
| | | | | | | | | | | Required for porting away from QLatin1Char/QLatin1String in scope of QTBUG-98434. As a drive-by, fix qsizetype -> int narrowing conversion warnings for the touched lines. Change-Id: I121f87214b77aeab1dfd3e62dc5adaa6255cc0e0 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QtNetwork: sweep Q_DECLARE_METATYPE → QT_DECL_METATYPE_EXTERN [1/2]: ↵Marc Mutz2022-04-052-2/+7
| | | | | | | | | | | | | | public API It's one of our best tools to improve compile times. Can't backport to Qt 6.3 or 6.2 because this change introduces new exported symbols. Task-number: QTBUG-102206 Change-Id: I6bfa532be34ca847d3b9034d16c94efed3d602c3 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Add missing includes for some of our _win.cpp filesMårten Nordheim2022-03-181-0/+1
| | | | | Change-Id: I74067f5d50bea6fbc16576c26bf84f91e449e497 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Misc: Do not depend on transitive includesFabian Kosmale2022-03-171-0/+1
| | | | | | | | As a drive-by, remove superfluous includes from qnetworkmanagerservice.h and obey the coding conventions for includes in a few more places. Change-Id: I65b68c0cef7598d06a125e97637040392d4be9ff Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QAbstractSocket: update setSocketOption documentationMårten Nordheim2022-03-081-0/+4
| | | | | | | | | | | | | | | | | Specify that it should not be called until the internal socket engine has been created. Given that most usages of this function will be on QUdpSockets and that people will likely want to call bind() on those anyway, we just document this rather than implement some caching mechanism. Pick-to: 6.3 6.2 Fixes: QTBUG-67576 Change-Id: Ia5d3ade95460b7c5685681ee098f1c00bff43a90 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix deprecated uses of QScopedPointerMårten Nordheim2022-03-081-2/+4
| | | | | | | | | By changing it to unique_ptr. Pick-to: 6.2 6.3 Change-Id: I91abb69445b537d4c95983ae735341882352b29d Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QAbstractSocket: remove note about WinRTMårten Nordheim2022-03-051-3/+0
| | | | | | | | It's no longer supported Pick-to: 6.3 6.2 Change-Id: I751ed0904f17e11c65bd60b55e11db9066d01ab2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix Q_FLAG declaration over enumerationsGiuseppe D'Angelo2022-03-021-1/+1
| | | | | | | | | | One should use Q_ENUM, not Q_FLAG, to mark an enumeration. Q_FLAG should go on the respective flag type. Change-Id: I16cd5c0d405c3db1951569b72805fdae18898c45 Pick-to: 5.15 6.2 6.3 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QNX: Fix support for abstract Unix-domain socketPasi Petäjäjärvi2022-02-241-0/+4
| | | | | | | | | | | | As QNX claims to support abstract Unix-domain sockets, its getsockname always returns for socket that has not been bound to local name address_len of sun_path as maximum length (106) even when it does not contain valid address. https://www.qnx.com/developers/docs/7.1/index.html#com.qnx.doc.neutrino.lib_ref/topic/u/unix_proto.html Pick-to: 6.2 6.3 Change-Id: I0f0f5c05611c8db6af35377dde16450f58c83c56 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* 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>
* qtextstream.h: streamline includesFabian Kosmale2022-02-101-0/+1
| | | | | | | | | | | [ChangeLog][Potentially Source-Incompatible Changes] The qtextstream header no longer includes <QString>, <QStringEncoder> and <QStringDecoder>. Code which relied on the implicit inclusion of those classes might now need to include the headers explicitly. Task-number: QTBUG-97601 Change-Id: Ifb8c8452026195a772c0588dbbbc53fb51cac548 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QAbstractSocketPrivate: Initialize members in-classMårten Nordheim2022-02-092-38/+20
| | | | | Change-Id: I267b5037801f226379a154731be9ef81cccb828e Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* QAbstractSocket: Don't pretend pause and resume is a stackMårten Nordheim2022-02-092-14/+41
| | | | | | | | | | | | | | | | It only stores one layer of state, and pausing twice in a row will just overwrite the previous state. This doesn't happen often but can happen, especially on Windows if a certificate needs to be looked up in the system certificate stores (socket gets paused) and then a recoverable error occurs in QNAM (socket gets paused again). Fixes: QTBUG-100362 Fixes: QTBUG-63196 Fixes: QTBUG-98476 Pick-to: 6.3 6.2 5.15 Change-Id: Ie524c48e11b6fa8010b78cc1bf3931efe2ce3351 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* QSocks5: Un-virtualize what is never overriddenMårten Nordheim2022-02-091-3/+3
| | | | | | Change-Id: Iec9f56ff24c94f05eba4fc54fa48df3af3de7801 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QtNetwork: Include moc filesMårten Nordheim2022-01-153-0/+6
| | | | | Change-Id: I227a9541bf76c1c048a694f022b8fc419c0c2544 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QRingBuffer: overload append() for rvaluesMarc Mutz2021-12-151-1/+1
| | | | | | | | | | | | The majority of append() callers in QtBase pass rvalues, so overload append() to avoid the need for manipulating QBA's atomic ref counts. Also adjust a caller that could pass by rvalue, but didn't, to do so. Pick-to: 6.3 Change-Id: I3d9e60b0d04ef837bfdc526e1f0f691a151006f9 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* wasm: implement host lookup for socket tunnelingMorten Johan Sørvig2021-12-151-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Emscripten implements support for tunneling TCP and UDP sockets through a WebSockets connection. This support is implement for the BSD sockets API, which means that Qt’s existing socket classes can be used, with some adjustments. For example, the flow for making a TCP connection to example.com:1515 can look like this: 1) The application resolves “example.com”. Emscripten creates an internal mapping to a private IP and returns that IP: 172.29.1.0. 2) The application connects to 172.29.1.0:1515. Emscripten makes a WebSocket connection to example.com:1515, and forwards the TCP data over this connection 3) On example.com:1515, a WebSockify intermediate server accepts the WebScoket connection and forwards the TCP data to the target sever, as specified by the WebSockify configuration. Emscripten’s local getaddrinfo() implementation is fast, which means don’t need caching or the thread pool. Instead, special-case lookupHostImpl() for Q_OS_WASM. The implementation calls QHostInfoAgent::lookup() and then posts resultReady using QHostInfoResult. Change-Id: Iaf31efb701ae7cc11752a63cc6b8346d4f09107e Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* QObject: Q_ASSERT the object type before calling a PMFThiago Macieira2021-11-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | The old-syle signal-slot syntax had the advantage of not delivering signals to slots in derived classes after that derived class's destructor had finished running (because we called via the virtual qt_metacall). The new syntax made no checks, so a conversion from the old to the new syntax may introduce crashes or other data corruptions at runtime if the destructor had completed. This commit introduces a Q_ASSERT to print the class name that the object is not any more. Since this is in inline code, this should get enabled for users' debug modes and does not therefore depend on Qt being built in debug mode. It required some Private classes to be adapted to the new form, by exposing the public q_func() in the public: part. Pick-to: 6.2 Fixes: QTBUG-33908 Change-Id: Iccb47e5527544b6fbd75fffd16b874cdc08c1f3e Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* network: Fix typos in source code commentsJonas Kvinge2021-10-124-6/+6
| | | | | | Change-Id: Iff505451e3f00de2d753de0f1d891a73cf73ef0d Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* network: Fix typos in messagesJonas Kvinge2021-10-121-1/+1
| | | | | | Pick-to: 5.15 6.2 Change-Id: Ibad852372c80a988efeabc2b0757bf238b92b9a3 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* network: Fix typos in documentationJonas Kvinge2021-10-123-3/+3
| | | | | | | Pick-to: 5.15 6.2 Change-Id: I386c6e4a21dacb2553a39a073052dcf6d92a9854 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QLocalSocket/Win: stop reading in close()Alex Trotsenko2021-10-061-0/+1
| | | | | | | | | | After calling close(), the socket can enter 'Closing' state, in which we try to write buffered data before disconnecting. As the device is already closed, we must disable any pipe reader activity and clear the read buffer. Change-Id: I8994df32bf324325d54dd36cbe1a1ee3f08022d1 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QLocalSocket/Win: add missing check to waitForBytesWritten()Alex Trotsenko2021-10-051-1/+1
| | | | | | | | | | | | | | | Calling pipeWriter->checkForWrite() can indirectly close the socket even if the bytesWritten() signal has not been sent. So, we need to make sure the handle is valid before checking pipe state in the reader. There is no harm in calling PeekNamedPipe() with an invalid handle, but the wrong call should be avoided. This patch amends b2c3b3e8fe0d8bdc88051d0120aaa8d5cf8acce0. Change-Id: I5d2ecbbbe0af817aac68ad6f1173b0ed9b324e98 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* Doc: Update Microsoft's Documentation LinksLuca Di Sera2021-09-232-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | The documentation links on `msdn.microsoft.com` now redirect to `docs.microsoft.com`. While the redirection works, our script to catch broken links on dev-snapshots builds of the documentation doesn't handle redirection correctly, reporting it as broken. Both to appease the broken-links script and to avoid an unneccesary redirection, the links were modified to point to the equivalent address in the new domain. Furthermore, the link to the `Winsock 2 Socket Handle` was moved to be an `\externalpage` link, as it was used in two different places. Additionally, the `\externalpage` link titled `Dirext X SDK` was removed as it was not used in any part of the documentation. Task-number: QTBUG-96127 Pick-to: 6.2 6.2.0 Change-Id: I07f0ae8d610a7f8322b892a2fa37a5cc1769289e Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QLocalSocket: reorder device closingAlex Trotsenko2021-09-212-2/+4
| | | | | | | | | | | To allow reading from a slot connected to the aboutToClose() signal, we should call QIODevice::close() just before closing the inner device. This patch amends 21f3ff65b8df777b5726a68b09bbee39f1a893ec. Pick-to: 6.2 Change-Id: Ic8cd00497e1bdf923b980c26e9ca874b77e82f89 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* Q{LocalSocket|Process}/Win: handle write errorsAlex Trotsenko2021-09-182-0/+13
| | | | | | | | | To match the Unix behavior, we should emit errorOccurred() signal and close the channel if the write operation fails. Change-Id: Iac3acb18dbbfe6e7e8afb2555d9adaff1fe98d0f Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QWindowsPipeWriter: do not clear the buffer in thread pool callbackAlex Trotsenko2021-09-181-1/+1
| | | | | | | | | | | | | | | | | In a blocking application, receiving the results of write operations must be synchronized with the waitFor...() functions. But, clearing the buffer in another thread can cause the code localsocket.write(...); QVERIFY(localsocket.bytesToWrite() > 0); to fail unexpectedly, if the socket has been disconnected between the calls. So, defer resetting the buffer until checkForWrite() is called. Change-Id: I8c21036aab6a4c56d02c0d9a18d4bbce52d724f4 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* Doc: Update a link to Windows SocketsLuca Di Sera2021-09-101-1/+1
| | | | | | | | | | | | | | | | | | | The link was to `msdn.microsoft.com` which now redirects to `docs.microsoft.com`. While the redirection works, our script to catch broken links on dev-snapshots builds of the documentation doesn't handle redirection correctly, reporting it as broken. Both to appease the broken-links script and to avoid an unneccesary redirection, the Winsock link in `qlocalsocket.cpp` was modified to point to the new address. Task-number: QTBUG-96127 Pick-to: 6.2 Change-Id: Idff5c2e96f7c90259219a554f73e16c37b81cafe Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Move QNAM's http header parsing into separate classØystein Heskestad2021-09-091-1/+1
| | | | | | Fixes: QTBUG-80701 Change-Id: I43f5e102c15d121dba74e07e3cd4bb8aded1c763 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Doc: Fix documentation warnings for Qt NetworkTopi Reinio2021-09-081-1/+4
| | | | | | | | | | | | | | | | The Clang compiler used in QDoc complained about the documentation- specific overload of QAbstractSocket::bind(): error: incomplete type 'QHostAddress' named in nested name specifier Also, fix an attempted snippet inclusion to use the \include command, and fix the comment tag spacing and indentation. Pick-to: 6.2 Fixes: QTBUG-96293 Change-Id: Ie4d78933fa7ac0aaf7f3bcc6487e7fd823db5123 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* Doc: mark documentation of internal functions as such to silence qdocVolker Hilsheimer2021-09-061-0/+2
| | | | | | | | Pick-to: 6.2 Change-Id: I9523511b9adf40d1280fbf320c24a79aa2860ef2 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Luca Di Sera <luca.disera@qt.io>
* QLocalSocket/Win: fix waitFor...() functions for write-only socketAlex Trotsenko2021-09-021-8/+36
| | | | | | | | | | | | | | | | | There were several issues with the socket state checking when the pipe reader is not running: - the number of object handles in the WaitForMultipleObjectsEx() call might have been zero; - a call to the waitForDisconnected(-1) might have hung; - we did not perform a loop iteration for the waitFor...(0) calls, so disconnect detection was unreliable. These issues are related to the same code, so they don't seem to be addressable separately. Change-Id: I3bca872bb4191e6a7d38a693d81f7981af7fe145 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QLocalSocket: always open outer QIODevice in unbuffered modeAlex Trotsenko2021-08-012-1/+3
| | | | | | | | | | | The actual buffering is performed either in the inner socket (Unix), or in the pipeReader (Windows). To avoid unnecessary copying of data between buffers, enforce unbuffered mode for all implementations, which slightly improves read performance. Change-Id: Idb2a09f35823b9945c71231710290be12d9930f7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QLocalSocket: do not emit aboutToClose() twiceAlex Trotsenko2021-08-012-2/+0
| | | | | | | | | This signal is emitted by the QIODevice itself, so we don't have to forward it from the internal socket. Pick-to: 6.1 6.2 Change-Id: I85745f36d7a27d92f339a9184de3b6e5d46f6f34 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* Allow to set Local Socket listen(2) backlogDaniel Nicoletti2021-07-278-14/+46
| | | | | | | | | | | | | | | Unix sockets do not suffer from SYN flood, thus the hardcoded value to 50 is size of the only queue to hold connections to be accepted, resulting in dropped connections when the limit is reached. On Windows the hardcoded value is 8, this patch changes the default to 50 matching UNIX. [ChangeLog][QtNetwork][QLocalServer] Added setListenBacklogSize() to be able to have control over the listen backlog feature. Change-Id: Iaee6349a46b75b0bd05e40e7ade5948f1cf9f407 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QLocalSocket/Win: allow delayed close to workAlex Trotsenko2021-07-252-16/+9
| | | | | | | | | | | | This mechanism was neither properly designed nor correctly tested initially on Windows. [ChangeLog][QtNetwork][Important Behavior Changes] QLocalSocket on Windows now implements delayed closing, which is consistent with the behavior on Unix. Change-Id: Ic3bc427e68eea7f18201f6129df19fbc87d68101 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QLocalSocket/Win: do not close the device on disconnectFromServer()Alex Trotsenko2021-07-241-5/+7
| | | | | | | | | | | | | It's the user's privilege to do so when they want to finish reading the QIODevice. Moreover, this is the only difference between close() and disconnectFromServer(). [ChangeLog][QtNetwork][Important Behavior Changes] The Windows implementation of QLocalSocket::disconnectFromServer() no longer calls close(), which is consistent with the behavior on Unix. Change-Id: Ie9ce20c60259a2b08f5254b719355bd7be9b17cd Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QLocalSocket/Win: do not flush the pipe in disconnectFromServer()Alex Trotsenko2021-07-241-1/+0
| | | | | | | | | | | | | | | | | | In the case where we have pending data to write, calling flush() here may cause the device to close immediately, if the pipe writer already got a result of the last operation from the thread pool. In this scenario, the device does not enter the 'Closing' state, which leads the following code to unexpectedly fail on Windows socket.write(...); socket.disconnectFromServer(); QVERIFY(socket.waitForDisconnected()); Removing the call to flush() makes the behavior consistent with the implementation on Unix. Change-Id: Ic31fbc999be979c1e5befa8f132d9fb367f472ca Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QLocalSocket: call abort() instead of close() on destructionAlex Trotsenko2021-07-243-13/+9
| | | | | | | | | | | | The QLocalSocket destructor should immediately close the connection and destroy the socket, clearing any pending data in the write buffer. The abort() call ensures that the pipe is destroyed on Windows, making the additional call to destroyPipeHandles() from the private destructor unnecessary. Change-Id: Ic7a0d8cf2779cd933cded864c8bab0d096469499 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QLocalSocket/Win: remove unnecessary call to setWriteChannelCount()Alex Trotsenko2021-07-241-1/+0
| | | | | | | | | | We no longer use the QIODevice's internal write buffer. This patch amends 5b78d7fdcf9b758f117eaa65dc5eeddd0d4557e0 . Change-Id: Ife5a6ba3c2216d5a3e0a8278da98e0a36886d765 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QLocalSocket/Win: remove dead code in disconnectFromServer()Alex Trotsenko2021-07-241-8/+0
| | | | | | | | | The _q_pipeClosed() slot unconditionally removes the pipeWriter just before closing the pipe. Thus, if we have an invalid handle here, the pipe writer has already been destroyed anyway. Change-Id: I57463d8464afe6141c21a63851a56ebddabd3f13 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QLocalSocket/Unix: fix aborting the socketAlex Trotsenko2021-07-242-0/+2
| | | | | | | | | | | | | | | | | | According to the documentation, calling abort() should immediately reset the socket to its initial state. This includes: - closing the file descriptor; - closing the QLocalSocket as an I/O device; - canceling a pending outgoing connection, if it exist; - reseting 'serverName' string. So, adding a call to close() resets the state entirely. Pick-to: 6.1 6.2 Change-Id: I9c604b5187c6300b437d7aa4c2d06db03edacf21 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Allow to set TCP network listen(2) backlogDaniel Nicoletti2021-07-1910-13/+44
| | | | | | | | | | | | | | | | | | | | Qt has a hardcoded backlog value of 50, this allows for applications to tune this value. Modern kernels have the SYN cookie feature that reduces pressure from an flood attack, the backlog setting however is then a queue for most likely real completed (SYN/ACK) connections hence, it's easy to get clients connections dropped with this very small limit. [ChangeLog][QtNetwork][QTcpServer] Added QTcpServer::setListenBacklog() to be able to have control over the listen backlog feature. Change-Id: I1c78af6d99e012591e214b7e09fa85c485880d48 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QLocalSocket/Win: destroy the pipe before emitting final signalsAlex Trotsenko2021-07-141-4/+5
| | | | | | | | | | | | | | | | Both readChannelFinished() and disconnected() signals should be emitted after closing the pipe. Otherwise, these signals do not correspond to the state of the socket and may even be resent, if a slot connected to one of these signals processes events. [ChangeLog][QtNetwork][Important Behavior Changes] QLocalSocket on Windows now emits both readChannelFinished() and disconnected() signals after closing the pipe and emitting stateChanged(UnconnectedState), which is consistent with the behavior on Unix. Pick-to: 6.2 Change-Id: I1cc551b7897fdba3cec1fd6705f5396790818c7d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QLocalServer/Unix: don't allocate QTemporaryDir just to make it optional<>Marc Mutz2021-07-121-2/+4
| | | | | | | Use std::optional<> instead. Change-Id: Ic33ae2dd71f2b6c4347dac7c4be4dc6227edf425 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>