summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorAndrew Stitcher <astitcher@apache.org>2010-09-08 16:48:31 +0000
committerAndrew Stitcher <astitcher@apache.org>2010-09-08 16:48:31 +0000
commit18dc691d6bb3cdcc359f70cff064f51eeae51c4d (patch)
tree0191806925e31db110bc460bc6afe27ea45ae603 /cpp/src
parent273a36a5951ab881a6778079de36a93e52543223 (diff)
downloadqpid-python-18dc691d6bb3cdcc359f70cff064f51eeae51c4d.tar.gz
Changed RDMA testing server not to use the lower level Rdma buffers
if it needs to queue messages to echo, but to suffer the double copy overhead of using its own buffers git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@995125 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/qpid/sys/rdma/RdmaServer.cpp46
1 files changed, 35 insertions, 11 deletions
diff --git a/cpp/src/qpid/sys/rdma/RdmaServer.cpp b/cpp/src/qpid/sys/rdma/RdmaServer.cpp
index 97715326d5..564fd62730 100644
--- a/cpp/src/qpid/sys/rdma/RdmaServer.cpp
+++ b/cpp/src/qpid/sys/rdma/RdmaServer.cpp
@@ -44,10 +44,28 @@ using qpid::sys::Dispatcher;
namespace qpid {
namespace tests {
+struct Buffer {
+ char* bytes() const {return bytes_;}
+ int32_t byteCount() const {return size;}
+
+ Buffer(const int32_t s):
+ bytes_(new char[s]),
+ size(s)
+ {
+ }
+
+ ~Buffer() {
+ delete [] bytes_;
+ }
+private:
+ char* bytes_;
+ int32_t size;
+};
+
struct ConRec {
Rdma::Connection::intrusive_ptr connection;
Rdma::AsynchIO* data;
- queue<Rdma::Buffer*> queuedWrites;
+ queue<Buffer*> queuedWrites;
ConRec(Rdma::Connection::intrusive_ptr c) :
connection(c)
@@ -60,30 +78,36 @@ void dataError(Rdma::AsynchIO&) {
void idle(ConRec* cr, Rdma::AsynchIO& a) {
// Need to make sure full is not called as it would reorder messages
- while (!cr->queuedWrites.empty() && a.writable()) {
- Rdma::Buffer* buf = cr->queuedWrites.front();
+ while (!cr->queuedWrites.empty() && a.writable() && a.bufferAvailable()) {
+ Buffer* buf = cr->queuedWrites.front();
cr->queuedWrites.pop();
- a.queueWrite(buf);
+ Rdma::Buffer* rbuf = a.getBuffer();
+ std::copy(buf->bytes(), buf->bytes()+buf->byteCount(), rbuf->bytes());
+ rbuf->dataCount(buf->byteCount());
+ delete buf;
+ a.queueWrite(rbuf);
}
}
void data(ConRec* cr, Rdma::AsynchIO& a, Rdma::Buffer* b) {
// Echo data back
- Rdma::Buffer* buf = a.getBuffer();
- std::copy(b->bytes(), b->bytes()+b->dataCount(), buf->bytes());
- buf->dataCount(b->dataCount());
- if (cr->queuedWrites.empty()) {
- // If can't write then full will be called and push buffer on back of queue
+ if (cr->queuedWrites.empty() && a.writable() && a.bufferAvailable()) {
+ Rdma::Buffer* buf = a.getBuffer();
+ std::copy(b->bytes(), b->bytes()+b->dataCount(), buf->bytes());
+ buf->dataCount(b->dataCount());
a.queueWrite(buf);
} else {
+ Buffer* buf = new Buffer(b->dataCount());
+ std::copy(b->bytes(), b->bytes()+b->dataCount(), buf->bytes());
cr->queuedWrites.push(buf);
// Try to empty queue
idle(cr, a);
}
}
-void full(ConRec* cr, Rdma::AsynchIO&, Rdma::Buffer* buf) {
- cr->queuedWrites.push(buf);
+void full(ConRec*, Rdma::AsynchIO&, Rdma::Buffer*) {
+ // Shouldn't ever be called
+ cout << "!";
}
void drained(Rdma::AsynchIO&) {