From b5f8cf1bd9b5652e2691d6bc5b9b1c3228f53d68 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Tue, 5 Aug 2008 19:29:09 +0000 Subject: Fix Cluster::send encode race. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@682885 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/cluster/Cluster.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'cpp/src/qpid/cluster/Cluster.cpp') diff --git a/cpp/src/qpid/cluster/Cluster.cpp b/cpp/src/qpid/cluster/Cluster.cpp index d18fd452e4..1d81a50e1c 100644 --- a/cpp/src/qpid/cluster/Cluster.cpp +++ b/cpp/src/qpid/cluster/Cluster.cpp @@ -109,8 +109,7 @@ template void encodePtr(Buffer& buf, T* ptr) { void Cluster::send(const AMQFrame& frame, ConnectionInterceptor* connection) { QPID_LOG(trace, "MCAST [" << connection << "] " << frame); - // FIXME aconway 2008-07-03: More efficient buffer management. - // Cache coded form of decoded frames for re-encoding? + char buffer[64*1024]; // FIXME aconway 2008-07-04: buffer management. Buffer buf(buffer); frame.encode(buf); encodePtr(buf, connection); @@ -161,7 +160,8 @@ void Cluster::deliver( try { Buffer buf(static_cast(msg), msg_len); AMQFrame frame; - frame.decode(buf); + if (!frame.decode(buf)) // Not enough data. + throw Exception("Received incomplete cluster event."); // FIXME aconway 2008-08-05: cluster error handling. ConnectionInterceptor* connection; decodePtr(buf, connection); QPID_LOG(trace, "DLVR [" << from << " " << connection << "] " << frame); @@ -170,7 +170,6 @@ void Cluster::deliver( QPID_LOG(warning, "Unexpected DLVR, already left the cluster."); return; } - if (connection && from != self) // Look up shadow for remote connections connection = getShadowConnection(from, connection); -- cgit v1.2.1