QAbstractSocket: remove disconnect timer
Nowadays, there is no need for this additional timer. It was intended to forcibly disconnect the socket if an appropriate write notification has not arrived. After several fixes in the notification system this does not occur anymore, because otherwise we might have seen the hangs in the regular data transmitting. Also, it can break a delaying disconnect of the socket, if a write chunk is large enough. Task-number: QTBUG-63000 Change-Id: I9b9fd46af0209f9ce006a6d5ee5bfac9ea85482d Reviewed-by: Anthony Groyer <anthony.groyer@airliquide.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
e0c2d328b1
commit
bcd81a9e2d
@ -565,7 +565,6 @@ QAbstractSocketPrivate::QAbstractSocketPrivate()
|
|||||||
isBuffered(false),
|
isBuffered(false),
|
||||||
hasPendingData(false),
|
hasPendingData(false),
|
||||||
connectTimer(0),
|
connectTimer(0),
|
||||||
disconnectTimer(0),
|
|
||||||
hostLookupId(-1),
|
hostLookupId(-1),
|
||||||
socketType(QAbstractSocket::UnknownSocketType),
|
socketType(QAbstractSocket::UnknownSocketType),
|
||||||
state(QAbstractSocket::UnconnectedState),
|
state(QAbstractSocket::UnconnectedState),
|
||||||
@ -604,8 +603,6 @@ void QAbstractSocketPrivate::resetSocketLayer()
|
|||||||
}
|
}
|
||||||
if (connectTimer)
|
if (connectTimer)
|
||||||
connectTimer->stop();
|
connectTimer->stop();
|
||||||
if (disconnectTimer)
|
|
||||||
disconnectTimer->stop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \internal
|
/*! \internal
|
||||||
@ -1222,15 +1219,6 @@ void QAbstractSocketPrivate::_q_abortConnectionAttempt()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QAbstractSocketPrivate::_q_forceDisconnect()
|
|
||||||
{
|
|
||||||
Q_Q(QAbstractSocket);
|
|
||||||
if (socketEngine && socketEngine->isValid() && state == QAbstractSocket::ClosingState) {
|
|
||||||
socketEngine->close();
|
|
||||||
q->disconnectFromHost();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! \internal
|
/*! \internal
|
||||||
|
|
||||||
Reads data from the socket layer into the read buffer. Returns
|
Reads data from the socket layer into the read buffer. Returns
|
||||||
@ -2753,20 +2741,6 @@ void QAbstractSocket::disconnectFromHost()
|
|||||||
// Wait for pending data to be written.
|
// Wait for pending data to be written.
|
||||||
if (d->socketEngine && d->socketEngine->isValid() && (!d->allWriteBuffersEmpty()
|
if (d->socketEngine && d->socketEngine->isValid() && (!d->allWriteBuffersEmpty()
|
||||||
|| d->socketEngine->bytesToWrite() > 0)) {
|
|| d->socketEngine->bytesToWrite() > 0)) {
|
||||||
// hack: when we are waiting for the socket engine to write bytes (only
|
|
||||||
// possible when using Socks5 or HTTP socket engine), then close
|
|
||||||
// anyway after 2 seconds. This is to prevent a timeout on Mac, where we
|
|
||||||
// sometimes just did not get the write notifier from the underlying
|
|
||||||
// CFSocket and no progress was made.
|
|
||||||
if (d->allWriteBuffersEmpty() && d->socketEngine->bytesToWrite() > 0) {
|
|
||||||
if (!d->disconnectTimer) {
|
|
||||||
d->disconnectTimer = new QTimer(this);
|
|
||||||
connect(d->disconnectTimer, SIGNAL(timeout()), this,
|
|
||||||
SLOT(_q_forceDisconnect()), Qt::DirectConnection);
|
|
||||||
}
|
|
||||||
if (!d->disconnectTimer->isActive())
|
|
||||||
d->disconnectTimer->start(2000);
|
|
||||||
}
|
|
||||||
d->socketEngine->setWriteNotificationEnabled(true);
|
d->socketEngine->setWriteNotificationEnabled(true);
|
||||||
|
|
||||||
#if defined(QABSTRACTSOCKET_DEBUG)
|
#if defined(QABSTRACTSOCKET_DEBUG)
|
||||||
|
@ -231,7 +231,6 @@ private:
|
|||||||
Q_PRIVATE_SLOT(d_func(), void _q_startConnecting(const QHostInfo &))
|
Q_PRIVATE_SLOT(d_func(), void _q_startConnecting(const QHostInfo &))
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_abortConnectionAttempt())
|
Q_PRIVATE_SLOT(d_func(), void _q_abortConnectionAttempt())
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_testConnection())
|
Q_PRIVATE_SLOT(d_func(), void _q_testConnection())
|
||||||
Q_PRIVATE_SLOT(d_func(), void _q_forceDisconnect())
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -95,7 +95,6 @@ public:
|
|||||||
void _q_startConnecting(const QHostInfo &hostInfo);
|
void _q_startConnecting(const QHostInfo &hostInfo);
|
||||||
void _q_testConnection();
|
void _q_testConnection();
|
||||||
void _q_abortConnectionAttempt();
|
void _q_abortConnectionAttempt();
|
||||||
void _q_forceDisconnect();
|
|
||||||
|
|
||||||
bool emittedReadyRead;
|
bool emittedReadyRead;
|
||||||
bool emittedBytesWritten;
|
bool emittedBytesWritten;
|
||||||
@ -148,7 +147,6 @@ public:
|
|||||||
bool hasPendingData;
|
bool hasPendingData;
|
||||||
|
|
||||||
QTimer *connectTimer;
|
QTimer *connectTimer;
|
||||||
QTimer *disconnectTimer;
|
|
||||||
|
|
||||||
int hostLookupId;
|
int hostLookupId;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user