1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-03-11 12:51:03 +00:00

Don't expire connection when there are data in buffer

For writing, this ensures expire handler won't be executed in a small
time window, that is after `m_socket->write()` and before
`QIODevice::bytesWritten()` signal.
For reading, this let the socket to have the chance to process the
received data instead of dropping it.

PR #15849.
This commit is contained in:
Chocobo1 2021-12-18 12:28:30 +08:00 committed by GitHub
parent aa3da942cb
commit aedd997604
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -134,7 +134,9 @@ void Connection::sendResponse(const Response &response) const
bool Connection::hasExpired(const qint64 timeout) const
{
return m_idleTimer.hasExpired(timeout);
return (m_socket->bytesAvailable() == 0)
&& (m_socket->bytesToWrite() == 0)
&& m_idleTimer.hasExpired(timeout);
}
bool Connection::isClosed() const