From 6502cce999a8276679e6a74049f739483a3fe7dd Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Thu, 28 Jan 2010 19:42:48 +0000 Subject: Fixed cluster error "Not enough for multicast header" Fixed incorrect test of message size. Added assertions. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@904232 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/assert.cpp | 4 +++- cpp/src/qpid/cluster/Event.cpp | 13 +++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/cpp/src/qpid/assert.cpp b/cpp/src/qpid/assert.cpp index bf36d3be86..801bfa6ae5 100644 --- a/cpp/src/qpid/assert.cpp +++ b/cpp/src/qpid/assert.cpp @@ -24,14 +24,16 @@ #include #include #include "qpid/framing/reply_exceptions.h" +#include "qpid/log/Statement.h" #include namespace qpid { void assert_fail(char const * expr, char const * function, char const * file, long line) { std::ostringstream msg; - msg << "Internal error: " << expr << " in function " << function + msg << "Assertion failed: " << expr << " in function " << function << "(" << file << ":" << line << ")"; + QPID_LOG(critical, msg.str()); #ifdef NDEBUG throw framing::InternalErrorException(msg.str()); #else diff --git a/cpp/src/qpid/cluster/Event.cpp b/cpp/src/qpid/cluster/Event.cpp index 52564990f6..cd775ce2f1 100644 --- a/cpp/src/qpid/cluster/Event.cpp +++ b/cpp/src/qpid/cluster/Event.cpp @@ -51,11 +51,9 @@ Event::Event(EventType t, const ConnectionId& c, size_t s) {} void EventHeader::decode(const MemberId& m, framing::Buffer& buf) { - if (buf.available() <= HEADER_SIZE) - throw Exception("Not enough for multicast header"); + QPID_ASSERT(buf.available() >= HEADER_SIZE); type = (EventType)buf.getOctet(); - if(type != DATA && type != CONTROL) - throw Exception("Invalid multicast event type"); + QPID_ASSERT(type == DATA || type == CONTROL); connectionId = ConnectionId(m, buf.getLongLong()); size = buf.getLong(); } @@ -63,8 +61,7 @@ void EventHeader::decode(const MemberId& m, framing::Buffer& buf) { Event Event::decodeCopy(const MemberId& m, framing::Buffer& buf) { Event e; e.decode(m, buf); // Header - if (buf.available() < e.size) - throw Exception("Not enough data for multicast event"); + QPID_ASSERT(buf.available() >= e.size); e.store = RefCountedBuffer::create(e.size + HEADER_SIZE); memcpy(e.getData(), buf.getPointer() + buf.getPosition(), e.size); return e; @@ -107,8 +104,8 @@ Event::operator Buffer() const { const AMQFrame& Event::getFrame() const { assert(type == CONTROL); if (!frame.getBody()) { - Buffer buf(*this); - QPID_ASSERT(frame.decode(buf)); + Buffer buf(*this); + QPID_ASSERT(frame.decode(buf)); } return frame; } -- cgit v1.2.1