summaryrefslogtreecommitdiff
path: root/cpp/lib/common
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2007-01-30 18:20:00 +0000
committerAlan Conway <aconway@apache.org>2007-01-30 18:20:00 +0000
commit98ccae7574a18f8d0a1f9e28e86ccfde4541c81f (patch)
tree528fe0c686b9193e66bdd222d0aee6c4705f34e7 /cpp/lib/common
parent53d097bd7e565d08f902671180be58d4b2a9d843 (diff)
downloadqpid-python-98ccae7574a18f8d0a1f9e28e86ccfde4541c81f.tar.gz
* client/* framing/*: fixed client-side request ID processing.
* cpp/tests/InProcessBroker.h: For tests: connect to an in-process broker directly, bypass the network. Keeps log of client/broker conversation for verification in test code. * cpp/tests/FramingTest.cpp (testRequestResponseRoundtrip): Client/broker round-trip test for request/reponse IDs and response mark. * APRAcceptor.cpp (APRAcceptor): fixed valgrind uninitialized error. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/qpid.0-9@501502 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/lib/common')
-rw-r--r--cpp/lib/common/framing/ChannelAdapter.cpp9
-rw-r--r--cpp/lib/common/framing/ChannelAdapter.h5
-rw-r--r--cpp/lib/common/framing/MethodContext.h4
-rw-r--r--cpp/lib/common/sys/apr/APRAcceptor.cpp5
4 files changed, 15 insertions, 8 deletions
diff --git a/cpp/lib/common/framing/ChannelAdapter.cpp b/cpp/lib/common/framing/ChannelAdapter.cpp
index 59dc93c287..1fdb8d6691 100644
--- a/cpp/lib/common/framing/ChannelAdapter.cpp
+++ b/cpp/lib/common/framing/ChannelAdapter.cpp
@@ -29,6 +29,7 @@ void ChannelAdapter::init(
id = i;
out = &o;
version = v;
+ context = MethodContext(id, this);
}
void ChannelAdapter::send(AMQFrame* frame) {
@@ -58,19 +59,21 @@ void ChannelAdapter::send(AMQBody::shared_ptr body) {
void ChannelAdapter::handleRequest(AMQRequestBody::shared_ptr request) {
assertMethodOk(*request);
responder.received(request->getData());
- MethodContext context(id, this, request->getRequestId());
+ context =MethodContext(id, this, request->getRequestId());
handleMethodInContext(request, context);
}
void ChannelAdapter::handleResponse(AMQResponseBody::shared_ptr response) {
assertMethodOk(*response);
- handleMethod(response);
+ // TODO aconway 2007-01-30: Consider a response handled on receipt.
+ // Review - any cases where this is not the case?
requester.processed(response->getData());
+ handleMethod(response);
}
void ChannelAdapter::handleMethod(AMQMethodBody::shared_ptr method) {
assertMethodOk(*method);
- MethodContext context(id, this);
+ context = MethodContext(id, this);
handleMethodInContext(method, context);
}
diff --git a/cpp/lib/common/framing/ChannelAdapter.h b/cpp/lib/common/framing/ChannelAdapter.h
index 60615740ad..b2a5ef6ff5 100644
--- a/cpp/lib/common/framing/ChannelAdapter.h
+++ b/cpp/lib/common/framing/ChannelAdapter.h
@@ -54,7 +54,7 @@ class ChannelAdapter : public BodyHandler, public OutputHandler {
/**
*@param output Processed frames are forwarded to this handler.
*/
- ChannelAdapter() : id(0), out(0) {}
+ ChannelAdapter() : context(0), id(0), out(0) {}
/** Initialize the channel adapter. */
void init(ChannelId, OutputHandler&, const ProtocolVersion&);
@@ -92,6 +92,9 @@ class ChannelAdapter : public BodyHandler, public OutputHandler {
RequestId getRequestInProgress() { return requestInProgress; }
+ protected:
+ MethodContext context;
+
private:
ChannelId id;
OutputHandler* out;
diff --git a/cpp/lib/common/framing/MethodContext.h b/cpp/lib/common/framing/MethodContext.h
index 1aa4be8f1e..46d2e064b5 100644
--- a/cpp/lib/common/framing/MethodContext.h
+++ b/cpp/lib/common/framing/MethodContext.h
@@ -50,7 +50,7 @@ struct MethodContext
: channelId(channel), out(output), requestId(request){}
/** \internal Channel on which the method is sent. */
- const ChannelId channelId;
+ ChannelId channelId;
/** Output handler for responses in this context */
OutputHandler* out;
@@ -58,7 +58,7 @@ struct MethodContext
/** \internal If we are in the context of processing an incoming request,
* this is the ID. Otherwise it is 0.
*/
- const RequestId requestId;
+ RequestId requestId;
};
diff --git a/cpp/lib/common/sys/apr/APRAcceptor.cpp b/cpp/lib/common/sys/apr/APRAcceptor.cpp
index 10f787f4fe..52384857ed 100644
--- a/cpp/lib/common/sys/apr/APRAcceptor.cpp
+++ b/cpp/lib/common/sys/apr/APRAcceptor.cpp
@@ -56,10 +56,11 @@ Acceptor::shared_ptr Acceptor::create(int16_t port, int backlog, int threads, bo
// Must define Acceptor virtual dtor.
Acceptor::~Acceptor() {}
- APRAcceptor::APRAcceptor(int16_t port_, int backlog, int threads, bool trace_) :
+APRAcceptor::APRAcceptor(int16_t port_, int backlog, int threads, bool trace_) :
port(port_),
trace(trace_),
- processor(APRPool::get(), threads, 1000, 5000000)
+ processor(APRPool::get(), threads, 1000, 5000000),
+ running(false)
{
apr_sockaddr_t* address;
CHECK_APR_SUCCESS(apr_sockaddr_info_get(&address, APR_ANYADDR, APR_UNSPEC, port, APR_IPV4_ADDR_OK, APRPool::get()));