diff options
| author | Ahmad Samir <a.samirh78@gmail.com> | 2023-07-31 20:05:05 +0300 |
|---|---|---|
| committer | Ahmad Samir <a.samirh78@gmail.com> | 2023-10-07 02:28:12 +0300 |
| commit | 032ffb70a829184fb620cf14fa146580b742e0e8 (patch) | |
| tree | 6994fa22f63b186007c9eb0b79afa4e71f8eeec9 /src/network/socket/qnativesocketengine.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 <qt_ci_bot@qt-project.org>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/network/socket/qnativesocketengine.cpp')
| -rw-r--r-- | src/network/socket/qnativesocketengine.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/network/socket/qnativesocketengine.cpp b/src/network/socket/qnativesocketengine.cpp index e2726be7817..6d0d22deadd 100644 --- a/src/network/socket/qnativesocketengine.cpp +++ b/src/network/socket/qnativesocketengine.cpp @@ -962,9 +962,9 @@ void QNativeSocketEngine::close() } /*! - Waits for \a msecs milliseconds or until the socket is ready for - reading. If \a timedOut is not \nullptr and \a msecs milliseconds - have passed, the value of \a timedOut is set to true. + Waits until \a deadline has expired or until the socket is ready for + reading. If \a timedOut is not \nullptr and \a deadline has expired, + the value of \a timedOut is set to true. Returns \c true if data is available for reading; otherwise returns false. @@ -976,7 +976,7 @@ void QNativeSocketEngine::close() is to create a QSocketNotifier, passing the socket descriptor returned by socketDescriptor() to its constructor. */ -bool QNativeSocketEngine::waitForRead(int msecs, bool *timedOut) +bool QNativeSocketEngine::waitForRead(QDeadlineTimer deadline, bool *timedOut) { Q_D(const QNativeSocketEngine); Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::waitForRead(), false); @@ -986,7 +986,7 @@ bool QNativeSocketEngine::waitForRead(int msecs, bool *timedOut) if (timedOut) *timedOut = false; - int ret = d->nativeSelect(msecs, true); + int ret = d->nativeSelect(deadline, true); if (ret == 0) { if (timedOut) *timedOut = true; @@ -1002,9 +1002,9 @@ bool QNativeSocketEngine::waitForRead(int msecs, bool *timedOut) } /*! - Waits for \a msecs milliseconds or until the socket is ready for - writing. If \a timedOut is not \nullptr and \a msecs milliseconds - have passed, the value of \a timedOut is set to true. + Waits until \a deadline has expired or until the socket is ready for + writing. If \a timedOut is not \nullptr and \a deadline has expired, + the value of \a timedOut is set to true. Returns \c true if data is available for writing; otherwise returns false. @@ -1016,7 +1016,7 @@ bool QNativeSocketEngine::waitForRead(int msecs, bool *timedOut) is to create a QSocketNotifier, passing the socket descriptor returned by socketDescriptor() to its constructor. */ -bool QNativeSocketEngine::waitForWrite(int msecs, bool *timedOut) +bool QNativeSocketEngine::waitForWrite(QDeadlineTimer deadline, bool *timedOut) { Q_D(QNativeSocketEngine); Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::waitForWrite(), false); @@ -1026,7 +1026,7 @@ bool QNativeSocketEngine::waitForWrite(int msecs, bool *timedOut) if (timedOut) *timedOut = false; - int ret = d->nativeSelect(msecs, false); + int ret = d->nativeSelect(deadline, false); // On Windows, the socket is in connected state if a call to // select(writable) is successful. In this case we should not // issue a second call to WSAConnect() @@ -1074,14 +1074,14 @@ bool QNativeSocketEngine::waitForWrite(int msecs, bool *timedOut) bool QNativeSocketEngine::waitForReadOrWrite(bool *readyToRead, bool *readyToWrite, bool checkRead, bool checkWrite, - int msecs, bool *timedOut) + QDeadlineTimer deadline, bool *timedOut) { Q_D(QNativeSocketEngine); Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::waitForReadOrWrite(), false); Q_CHECK_NOT_STATE(QNativeSocketEngine::waitForReadOrWrite(), QAbstractSocket::UnconnectedState, false); - int ret = d->nativeSelect(msecs, checkRead, checkWrite, readyToRead, readyToWrite); + int ret = d->nativeSelect(deadline, checkRead, checkWrite, readyToRead, readyToWrite); // On Windows, the socket is in connected state if a call to // select(writable) is successful. In this case we should not // issue a second call to WSAConnect() |
