initialize timeout to 0 for autoReconnect

Previously timeout was initialized to -1, which meant when it went
through delay loops it would always use a negative value. This closes
issue #9
This commit is contained in:
Matt Broadstone 2015-01-29 18:57:11 -05:00
parent 883172368a
commit bb13e2e830
1 changed files with 3 additions and 2 deletions

View File

@ -19,7 +19,7 @@ QAmqpClientPrivate::QAmqpClientPrivate(QAmqpClient *q)
host(AMQP_HOST),
virtualHost(AMQP_VHOST),
autoReconnect(false),
timeout(-1),
timeout(0),
connecting(false),
socket(0),
closed(false),
@ -157,7 +157,7 @@ void QAmqpClientPrivate::_q_heartbeat()
void QAmqpClientPrivate::_q_socketError(QAbstractSocket::SocketError error)
{
Q_Q(QAmqpClient);
if (timeout == 0) {
if (timeout <= 0) {
timeout = 1000;
} else {
if (timeout < 120000)
@ -183,6 +183,7 @@ void QAmqpClientPrivate::_q_socketError(QAbstractSocket::SocketError error)
socket->close();
if (autoReconnect) {
qAmqpDebug() << "trying to reconnect after: " << timeout << "ms";
QTimer::singleShot(timeout, q, SLOT(_q_connect()));
}
}