summaryrefslogtreecommitdiff
path: root/qpid/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/cpp/src')
-rw-r--r--qpid/cpp/src/qpid/framing/AMQFrame.cpp4
-rw-r--r--qpid/cpp/src/qpid/framing/Buffer.cpp16
-rw-r--r--qpid/cpp/src/qpid/framing/ProtocolInitiation.cpp2
-rw-r--r--qpid/cpp/src/qpid/management/Buffer.cpp3
-rw-r--r--qpid/cpp/src/qpid/management/ManagementAgent.cpp17
5 files changed, 16 insertions, 26 deletions
diff --git a/qpid/cpp/src/qpid/framing/AMQFrame.cpp b/qpid/cpp/src/qpid/framing/AMQFrame.cpp
index 5b9673f0d0..5e065d598c 100644
--- a/qpid/cpp/src/qpid/framing/AMQFrame.cpp
+++ b/qpid/cpp/src/qpid/framing/AMQFrame.cpp
@@ -85,7 +85,7 @@ bool AMQFrame::decode(Buffer& buffer)
{
if(buffer.available() < frameOverhead())
return false;
- buffer.record();
+ uint32_t pos = buffer.getPosition();
uint8_t flags = buffer.getOctet();
uint8_t framing_version = (flags & 0xc0) >> 6;
@@ -115,7 +115,7 @@ bool AMQFrame::decode(Buffer& buffer)
// B,E,b,e flags
uint16_t body_size = frame_size - frameOverhead();
if (buffer.available() < body_size){
- buffer.restore();
+ buffer.setPosition(pos);
return false;
}
diff --git a/qpid/cpp/src/qpid/framing/Buffer.cpp b/qpid/cpp/src/qpid/framing/Buffer.cpp
index 5a5bc0325e..b71915aeb7 100644
--- a/qpid/cpp/src/qpid/framing/Buffer.cpp
+++ b/qpid/cpp/src/qpid/framing/Buffer.cpp
@@ -23,27 +23,17 @@
#include "qpid/Msg.h"
#include <string.h>
#include <boost/format.hpp>
+
namespace qpid {
namespace framing {
+using std::string;
+
Buffer::Buffer(char* _data, uint32_t _size)
: size(_size), data(_data), position(0) {
}
-void Buffer::record(){
- r_position = position;
-}
-
-void Buffer::restore(bool reRecord){
- uint32_t savedPosition = position;
-
- position = r_position;
-
- if (reRecord)
- r_position = savedPosition;
-}
-
void Buffer::reset(){
position = 0;
}
diff --git a/qpid/cpp/src/qpid/framing/ProtocolInitiation.cpp b/qpid/cpp/src/qpid/framing/ProtocolInitiation.cpp
index e617015d64..00ddb55a3b 100644
--- a/qpid/cpp/src/qpid/framing/ProtocolInitiation.cpp
+++ b/qpid/cpp/src/qpid/framing/ProtocolInitiation.cpp
@@ -20,6 +20,8 @@
*/
#include "qpid/framing/ProtocolInitiation.h"
+#include <iostream>
+
namespace qpid {
namespace framing {
diff --git a/qpid/cpp/src/qpid/management/Buffer.cpp b/qpid/cpp/src/qpid/management/Buffer.cpp
index 7556b2a243..0ad6e9a851 100644
--- a/qpid/cpp/src/qpid/management/Buffer.cpp
+++ b/qpid/cpp/src/qpid/management/Buffer.cpp
@@ -29,12 +29,11 @@ namespace management {
Buffer::Buffer(char* data, uint32_t size) : impl(new framing::Buffer(data, size)) {}
Buffer::~Buffer() { delete impl; }
-void Buffer::record() { impl->record(); }
-void Buffer::restore(bool reRecord) { impl->restore(reRecord); }
void Buffer::reset() { impl->reset(); }
uint32_t Buffer::available() { return impl->available(); }
uint32_t Buffer::getSize() { return impl->getSize(); }
uint32_t Buffer::getPosition() { return impl->getPosition(); }
+void Buffer::setPosition(uint32_t p) { impl->setPosition(p); }
char* Buffer::getPointer() { return impl->getPointer(); }
void Buffer::putOctet(uint8_t i) { impl->putOctet(i); }
void Buffer::putShort(uint16_t i) { impl->putShort(i); }
diff --git a/qpid/cpp/src/qpid/management/ManagementAgent.cpp b/qpid/cpp/src/qpid/management/ManagementAgent.cpp
index 062a530706..7d90ed99d0 100644
--- a/qpid/cpp/src/qpid/management/ManagementAgent.cpp
+++ b/qpid/cpp/src/qpid/management/ManagementAgent.cpp
@@ -1344,18 +1344,19 @@ void ManagementAgent::handleMethodRequestLH(Buffer& inBuffer, const string& repl
outBuffer.putLong (Manageable::STATUS_PARAMETER_INVALID);
outBuffer.putMediumString(Manageable::StatusText (Manageable::STATUS_PARAMETER_INVALID));
}
- else
+ else {
+ uint32_t pos = outBuffer.getPosition();
try {
- outBuffer.record();
sys::Mutex::ScopedUnlock u(userLock);
string outBuf;
iter->second->doMethod(methodName, inArgs, outBuf, userId);
outBuffer.putRawData(outBuf);
} catch(exception& e) {
- outBuffer.restore();
+ outBuffer.setPosition(pos);;
outBuffer.putLong(Manageable::STATUS_EXCEPTION);
outBuffer.putMediumString(e.what());
}
+ }
}
outLen = MA_BUFFER_SIZE - outBuffer.available();
@@ -1662,11 +1663,11 @@ void ManagementAgent::handleSchemaResponseLH(Buffer& inBuffer, const string& /*r
string packageName;
SchemaClassKey key;
- inBuffer.record();
+ uint32_t pos = inBuffer.getPosition();
inBuffer.getOctet();
inBuffer.getShortString(packageName);
key.decode(inBuffer);
- inBuffer.restore();
+ inBuffer.setPosition(pos);;
QPID_LOG(debug, "RECV SchemaResponse class=" << packageName << ":" << key.name << "(" << Uuid(key.hash) << ")" << " seq=" << sequence);
@@ -2426,7 +2427,6 @@ size_t ManagementAgent::validateTableSchema(Buffer& inBuffer)
uint8_t hash[16];
try {
- inBuffer.record();
uint8_t kind = inBuffer.getOctet();
if (kind != ManagementItem::CLASS_KIND_TABLE)
return 0;
@@ -2468,7 +2468,7 @@ size_t ManagementAgent::validateTableSchema(Buffer& inBuffer)
}
end = inBuffer.getPosition();
- inBuffer.restore(); // restore original position
+ inBuffer.setPosition(start); // restore original position
return end - start;
}
@@ -2480,7 +2480,6 @@ size_t ManagementAgent::validateEventSchema(Buffer& inBuffer)
uint8_t hash[16];
try {
- inBuffer.record();
uint8_t kind = inBuffer.getOctet();
if (kind != ManagementItem::CLASS_KIND_EVENT)
return 0;
@@ -2507,7 +2506,7 @@ size_t ManagementAgent::validateEventSchema(Buffer& inBuffer)
}
end = inBuffer.getPosition();
- inBuffer.restore(); // restore original position
+ inBuffer.setPosition(start); // restore original position
return end - start;
}