diff options
author | Ahmad Samir <[email protected]> | 2023-07-31 20:05:05 +0300 |
---|---|---|
committer | Ahmad Samir <[email protected]> | 2023-10-07 02:28:12 +0300 |
commit | 032ffb70a829184fb620cf14fa146580b742e0e8 (patch) | |
tree | 6994fa22f63b186007c9eb0b79afa4e71f8eeec9 /src/network/socket/qnativesocketengine_unix.cpp | |
parent | 51c812af0747573ccf07fc232d860170c4ba2877 (diff) |
QAbstractSocketEngine: port to QDeadlineTimer
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 <[email protected]>
Reviewed-by: MÃ¥rten Nordheim <[email protected]>
Diffstat (limited to 'src/network/socket/qnativesocketengine_unix.cpp')
-rw-r--r-- | src/network/socket/qnativesocketengine_unix.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index 023a0dbc2c1..87c74f7f854 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -5,9 +5,9 @@ //#define QNATIVESOCKETENGINE_DEBUG #include "qnativesocketengine_p_p.h" #include "private/qnet_unix_p.h" +#include "qdeadlinetimer.h" #include "qiodevice.h" #include "qhostaddress.h" -#include "qelapsedtimer.h" #include "qvarlengtharray.h" #include "qnetworkinterface.h" #include "qendian.h" @@ -1344,16 +1344,17 @@ qint64 QNativeSocketEnginePrivate::nativeRead(char *data, qint64 maxSize) return qint64(r); } -int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool selectForRead) const +int QNativeSocketEnginePrivate::nativeSelect(QDeadlineTimer deadline, bool selectForRead) const { bool dummy; - return nativeSelect(timeout, selectForRead, !selectForRead, &dummy, &dummy); + return nativeSelect(deadline, selectForRead, !selectForRead, &dummy, &dummy); } #ifndef Q_OS_WASM -int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool checkRead, bool checkWrite, - bool *selectForRead, bool *selectForWrite) const +int QNativeSocketEnginePrivate::nativeSelect(QDeadlineTimer deadline, bool checkRead, + bool checkWrite, bool *selectForRead, + bool *selectForWrite) const { pollfd pfd = qt_make_pollfd(socketDescriptor, 0); @@ -1363,7 +1364,7 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool checkRead, bool c if (checkWrite) pfd.events |= POLLOUT; - const int ret = qt_poll_msecs(&pfd, 1, timeout); + const int ret = qt_poll_msecs(&pfd, 1, deadline.remainingTime()); if (ret <= 0) return ret; @@ -1384,13 +1385,16 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool checkRead, bool c #else -int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool checkRead, bool checkWrite, - bool *selectForRead, bool *selectForWrite) const +int QNativeSocketEnginePrivate::nativeSelect(QDeadlineTimer deadline, bool checkRead, + bool checkWrite, bool *selectForRead, + bool *selectForWrite) const { *selectForRead = checkRead; *selectForWrite = checkWrite; bool socketDisconnect = false; - QEventDispatcherWasm::socketSelect(timeout, socketDescriptor, checkRead, checkWrite,selectForRead, selectForWrite, &socketDisconnect); + QEventDispatcherWasm::socketSelect(deadline.remainingTime(), socketDescriptor, checkRead, + checkWrite, selectForRead, selectForWrite, + &socketDisconnect); // The disconnect/close handling code in QAbstractsScket::canReadNotification() // does not detect remote disconnect properly; do that here as a workardound. |