diff options
author | Alan Conway <aconway@apache.org> | 2010-01-28 19:42:48 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2010-01-28 19:42:48 +0000 |
commit | 6502cce999a8276679e6a74049f739483a3fe7dd (patch) | |
tree | 46570bd6c1a1ef43f93a4e9248eb4d89c84a19d1 | |
parent | fe2db915235fdca1c8ed2335e69127b43ee5b835 (diff) | |
download | qpid-python-6502cce999a8276679e6a74049f739483a3fe7dd.tar.gz |
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
-rw-r--r-- | cpp/src/qpid/assert.cpp | 4 | ||||
-rw-r--r-- | 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 <sstream> #include <iostream> #include "qpid/framing/reply_exceptions.h" +#include "qpid/log/Statement.h" #include <stdlib.h> 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; } |