From 9b3288ca9df1b8bb0f12612d52cf762635392839 Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Thu, 5 Mar 2015 14:20:30 -0500 Subject: [PATCH] only attempt to close socket if its open On socket errors we always close the socket per amqp specification, however there is no need to do so if the connection has already been forcibly closed from the server side. This causes recursive loops when using SSL connections --- src/qamqpclient.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/qamqpclient.cpp b/src/qamqpclient.cpp index a8dc142..d803587 100644 --- a/src/qamqpclient.cpp +++ b/src/qamqpclient.cpp @@ -193,8 +193,13 @@ void QAmqpClientPrivate::_q_socketError(QAbstractSocket::SocketError error) } // per spec, on any error we need to close the socket immediately - // and send no more data; - socket->close(); + // and send no more data. only try to send the close message if we + // are actively connected + if (socket->state() == QAbstractSocket::ConnectedState || + socket->state() == QAbstractSocket::ConnectingState) { + socket->abort(); + } + errorString = socket->errorString(); if (autoReconnect) {