summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/cluster/Event.cpp
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2008-12-03 02:55:54 +0000
committerAlan Conway <aconway@apache.org>2008-12-03 02:55:54 +0000
commitf9cccf7b8f346c415c5f9b7d52127ef67797b02d (patch)
tree2cfcbbb5f1f007a1c399a69bd26667ac318438a6 /cpp/src/qpid/cluster/Event.cpp
parent65c29f1810e2fa2e445f536db49218fcf4b0d6f4 (diff)
downloadqpid-python-f9cccf7b8f346c415c5f9b7d52127ef67797b02d.tar.gz
cluster: add Event size to encoded header.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@722728 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/cluster/Event.cpp')
-rw-r--r--cpp/src/qpid/cluster/Event.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/cpp/src/qpid/cluster/Event.cpp b/cpp/src/qpid/cluster/Event.cpp
index 0e55d7bce3..5ac63c86f5 100644
--- a/cpp/src/qpid/cluster/Event.cpp
+++ b/cpp/src/qpid/cluster/Event.cpp
@@ -32,20 +32,21 @@ namespace cluster {
using framing::Buffer;
-const size_t Event::OVERHEAD = sizeof(uint8_t) + sizeof(uint64_t) + sizeof(uint32_t);
+const size_t Event::OVERHEAD = sizeof(uint8_t) + sizeof(uint64_t) + sizeof(uint32_t) + sizeof(uint32_t);
Event::Event(EventType t, const ConnectionId& c, size_t s, uint32_t i)
: type(t), connectionId(c), size(s), data(RefCountedBuffer::create(s)), id(i) {}
-Event Event::delivered(const MemberId& m, void* d, size_t s) {
- Buffer buf(static_cast<char*>(d), s);
+Event Event::decode(const MemberId& m, framing::Buffer& buf) {
+ assert(buf.available() > OVERHEAD);
EventType type((EventType)buf.getOctet());
assert(type == DATA || type == CONTROL);
ConnectionId connection(m, reinterpret_cast<Connection*>(buf.getLongLong()));
uint32_t id = buf.getLong();
- assert(buf.getPosition() == OVERHEAD);
- Event e(type, connection, s-OVERHEAD, id);
- memcpy(e.getData(), static_cast<char*>(d)+OVERHEAD, s-OVERHEAD);
+ uint32_t size = buf.getLong();
+ Event e(type, connection, size, id);
+ assert(buf.available() >= size);
+ memcpy(e.getData(), buf.getPointer() + buf.getPosition(), size);
return e;
}
@@ -63,6 +64,7 @@ bool Event::mcast (Cpg& cpg) const {
b.putOctet(type);
b.putLongLong(reinterpret_cast<uint64_t>(connectionId.getPointer()));
b.putLong(id);
+ b.putLong(size);
assert(b.getPosition() == OVERHEAD);
iovec iov[] = { { header, OVERHEAD }, { const_cast<char*>(getData()), getSize() } };
return cpg.mcast(iov, sizeof(iov)/sizeof(*iov));