From 695f7d2997c1a478889910fd3a7ab819cade9cc5 Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Thu, 7 Aug 2014 14:12:28 -0400 Subject: [PATCH] complete close handshakes properly for Client and Channel We had frame handlers for Close messages from the server, but were not doing our due diligence and sending a corresponding CloseOk back to the server after processing. It seems RabbitMQ is generous in this case, but at least we're doing it the right way now --- src/amqp_channel.cpp | 9 ++++----- src/amqp_channel_p.h | 1 - src/amqp_client.cpp | 11 ++++------- src/amqp_client_p.h | 1 - 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/amqp_channel.cpp b/src/amqp_channel.cpp index 0e98a72..7d896c0 100644 --- a/src/amqp_channel.cpp +++ b/src/amqp_channel.cpp @@ -195,12 +195,11 @@ void ChannelPrivate::close(const Frame::Method &frame) qAmqpDebug(">> class-id: %d", classId); qAmqpDebug(">> method-id: %d", methodId); Q_EMIT q->closed(); -} -void ChannelPrivate::closeOk() -{ - Frame::Method frame(Frame::fcChannel, miCloseOk); - sendFrame(frame); + // complete handshake + Frame::Method closeOkFrame(Frame::fcChannel, miCloseOk); + closeOkFrame.setChannel(channelNumber); + sendFrame(closeOkFrame); } void ChannelPrivate::closeOk(const Frame::Method &) diff --git a/src/amqp_channel_p.h b/src/amqp_channel_p.h index 55ff08d..d3469c9 100644 --- a/src/amqp_channel_p.h +++ b/src/amqp_channel_p.h @@ -46,7 +46,6 @@ public: void flow(bool active); void flowOk(); void close(int code, const QString &text, int classId, int methodId); - void closeOk(); // reimp MethodHandler virtual bool _q_method(const Frame::Method &frame); diff --git a/src/amqp_client.cpp b/src/amqp_client.cpp index 901125e..c11027b 100644 --- a/src/amqp_client.cpp +++ b/src/amqp_client.cpp @@ -447,6 +447,10 @@ void ClientPrivate::close(const Frame::Method &frame) qAmqpDebug(">> method-id: %d", methodId); connected = false; Q_EMIT q->disconnected(); + + // complete handshake + Frame::Method closeOkFrame(Frame::fcConnection, ClientPrivate::miCloseOk); + sendFrame(closeOkFrame); } void ClientPrivate::startOk() @@ -517,13 +521,6 @@ void ClientPrivate::close(int code, const QString &text, int classId, int method sendFrame(frame); } -void ClientPrivate::closeOk() -{ - Frame::Method frame(Frame::fcConnection, ClientPrivate::miCloseOk); - connected = false; - sendFrame(frame); -} - ////////////////////////////////////////////////////////////////////////// Client::Client(QObject *parent) diff --git a/src/amqp_client_p.h b/src/amqp_client_p.h index c289d08..4f900ef 100644 --- a/src/amqp_client_p.h +++ b/src/amqp_client_p.h @@ -75,7 +75,6 @@ public: // method handlers, BOTH ways void close(int code, const QString &text, int classId = 0, int methodId = 0); void close(const Frame::Method &frame); - void closeOk(); quint16 port; QString host;