diff options
author | Alan Conway <aconway@apache.org> | 2008-01-11 01:28:31 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2008-01-11 01:28:31 +0000 |
commit | af880601b97602f02cf2ef1c8c29d65b2fe5a834 (patch) | |
tree | 3c263fe3360089037a9cb2dd9612df0185756699 /cpp | |
parent | 6005ad88685a4bad8bdaa986a8b94fdffc51b31e (diff) | |
download | qpid-python-af880601b97602f02cf2ef1c8c29d65b2fe5a834.tar.gz |
Fix bug in Connector - incorrect use of iterator.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@611009 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/src/qpid/client/Connector.cpp | 20 | ||||
-rw-r--r-- | cpp/src/qpid/client/Connector.h | 2 |
2 files changed, 11 insertions, 11 deletions
diff --git a/cpp/src/qpid/client/Connector.cpp b/cpp/src/qpid/client/Connector.cpp index 0e3afdd3f0..95314dcb40 100644 --- a/cpp/src/qpid/client/Connector.cpp +++ b/cpp/src/qpid/client/Connector.cpp @@ -166,7 +166,7 @@ struct Connector::Buff : public AsynchIO::BufferBase { ~Buff() { delete [] bytes;} }; -Connector::Writer::Writer() : aio(0), buffer(0), lastEof(frames.begin()) {} +Connector::Writer::Writer() : aio(0), buffer(0), lastEof(0) {} Connector::Writer::~Writer() { delete buffer; } @@ -180,7 +180,7 @@ void Connector::Writer::handle(framing::AMQFrame& frame) { Mutex::ScopedLock l(lock); frames.push_back(frame); if (frame.getEof()) { - lastEof = frames.end(); + lastEof = frames.size(); aio->notifyPendingWrite(); } QPID_LOG(trace, "SENT [" << this << "]: " << frame); @@ -206,18 +206,18 @@ void Connector::Writer::newBuffer(const Mutex::ScopedLock&) { } // Called in IO thread. -void Connector::Writer::write(sys::AsynchIO& aio_) { +void Connector::Writer::write(sys::AsynchIO&) { Mutex::ScopedLock l(lock); - assert(&aio_ == aio); assert(buffer); - for (Frames::iterator i = frames.begin(); i != lastEof; ++i) { - if (i->size() > encode.available()) writeOne(l); - assert(i->size() <= encode.available()); - i->encode(encode); + for (size_t i = 0; i < lastEof; ++i) { + AMQFrame& frame = frames[i]; + if (frame.size() > encode.available()) writeOne(l); + assert(frame.size() <= encode.available()); + frame.encode(encode); ++framesEncoded; } - frames.erase(frames.begin(), lastEof); - lastEof = frames.begin(); + frames.erase(frames.begin(), frames.begin()+lastEof); + lastEof = 0; if (encode.getPosition() > 0) writeOne(l); } diff --git a/cpp/src/qpid/client/Connector.h b/cpp/src/qpid/client/Connector.h index 9897789901..aefd91f6f4 100644 --- a/cpp/src/qpid/client/Connector.h +++ b/cpp/src/qpid/client/Connector.h @@ -56,7 +56,7 @@ class Connector : public framing::OutputHandler, sys::AsynchIO* aio; BufferBase* buffer; Frames frames; - Frames::iterator lastEof; // Points after last EOF in frames + size_t lastEof; // Position after last EOF in frames framing::Buffer encode; size_t framesEncoded; |