summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/cluster
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/qpid/cluster')
-rw-r--r--cpp/src/qpid/cluster/Cluster.cpp4
-rw-r--r--cpp/src/qpid/cluster/ConnectionInterceptor.cpp15
-rw-r--r--cpp/src/qpid/cluster/ConnectionInterceptor.h21
3 files changed, 30 insertions, 10 deletions
diff --git a/cpp/src/qpid/cluster/Cluster.cpp b/cpp/src/qpid/cluster/Cluster.cpp
index 3b7f32e822..6623d1cde0 100644
--- a/cpp/src/qpid/cluster/Cluster.cpp
+++ b/cpp/src/qpid/cluster/Cluster.cpp
@@ -208,6 +208,10 @@ void Cluster::handleMethod(Id from, ConnectionInterceptor* connection, AMQMethod
connection->deliverClosed();
break;
}
+ case CLUSTER_CONNECTION_DO_OUTPUT_METHOD_ID: {
+ connection->deliverDoOutput();
+ break;
+ }
default:
assert(0);
}
diff --git a/cpp/src/qpid/cluster/ConnectionInterceptor.cpp b/cpp/src/qpid/cluster/ConnectionInterceptor.cpp
index 5283ba9b1a..32c2054631 100644
--- a/cpp/src/qpid/cluster/ConnectionInterceptor.cpp
+++ b/cpp/src/qpid/cluster/ConnectionInterceptor.cpp
@@ -20,6 +20,7 @@
*/
#include "ConnectionInterceptor.h"
#include "qpid/framing/ClusterConnectionCloseBody.h"
+#include "qpid/framing/ClusterConnectionDoOutputBody.h"
#include "qpid/framing/AMQFrame.h"
namespace qpid {
@@ -37,6 +38,7 @@ ConnectionInterceptor::ConnectionInterceptor(
// Attach my functions to Connection extension points.
shift(receivedNext, connection->receivedFn, boost::bind(&ConnectionInterceptor::received, this, _1));
shift(closedNext, connection->closedFn, boost::bind(&ConnectionInterceptor::closed, this));
+ shift(doOutputNext, connection->doOutputFn, boost::bind(&ConnectionInterceptor::doOutput, this));
}
ConnectionInterceptor::~ConnectionInterceptor() {
@@ -79,4 +81,17 @@ void ConnectionInterceptor::deliverClosed() {
connection = 0;
}
+bool ConnectionInterceptor::doOutput() {
+ cluster.send(AMQFrame(in_place<ClusterConnectionDoOutputBody>()), this);
+ return false;
+}
+
+void ConnectionInterceptor::deliverDoOutput() {
+ // FIXME aconway 2008-07-16: review thread safety.
+ // All connection processing happens in cluster queue, only read & write
+ // (from mutex-locked frameQueue) happens in reader/writer threads.
+ //
+ doOutputNext();
+}
+
}} // namespace qpid::cluster
diff --git a/cpp/src/qpid/cluster/ConnectionInterceptor.h b/cpp/src/qpid/cluster/ConnectionInterceptor.h
index d499acb832..7a955ddd80 100644
--- a/cpp/src/qpid/cluster/ConnectionInterceptor.h
+++ b/cpp/src/qpid/cluster/ConnectionInterceptor.h
@@ -38,17 +38,16 @@ class ConnectionInterceptor {
ConnectionInterceptor(broker::Connection&, Cluster&,
Cluster::ShadowConnectionId shadowId=Cluster::ShadowConnectionId(0,0));
~ConnectionInterceptor();
+
+ Cluster::ShadowConnectionId getShadowId() const { return shadowId; }
- // Called on self-delivery
- void deliver(framing::AMQFrame& f);
+ bool isLocal() const { return shadowId == Cluster::ShadowConnectionId(0,0); }
- // Called on self-delivery of my own cluster.connection-close
+ // self-delivery of intercepted extension points.
+ void deliver(framing::AMQFrame& f);
void deliverClosed();
+ void deliverDoOutput();
- Cluster::ShadowConnectionId getShadowId() const { return shadowId; }
-
- bool isLocal() const { return shadowId == Cluster::ShadowConnectionId(0,0); }
-
private:
struct NullConnectionHandler : public qpid::sys::ConnectionOutputHandler {
void close() {}
@@ -57,12 +56,14 @@ class ConnectionInterceptor {
void activateOutput() {}
};
- // Functions to add to Connection extension points.
+ // Functions to intercept to Connection extension points.
void received(framing::AMQFrame&);
void closed();
+ bool doOutput();
- boost::function<void(framing::AMQFrame&)> receivedNext;
- boost::function<void()> closedNext;
+ boost::function<void (framing::AMQFrame&)> receivedNext;
+ boost::function<void ()> closedNext;
+ boost::function<bool ()> doOutputNext;
boost::intrusive_ptr<broker::Connection> connection;
Cluster& cluster;