summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2008-04-07 11:51:07 +0000
committerGordon Sim <gsim@apache.org>2008-04-07 11:51:07 +0000
commit89b1e87fbd2d567840322bc727fc2ea811f124cd (patch)
tree407288ed36c07e96a817e9f3563ec3b15446c3bd
parente4d5fa23c36700d085109c03a232eef3acaa1df1 (diff)
downloadqpid-python-89b1e87fbd2d567840322bc727fc2ea811f124cd.tar.gz
AsynchIoAcceptor.cpp: Limit output from codec to one buffer per 'idle' call.
PreviewConnectionCodec: Generate output frames for encoding while available and while they can fit in the buffer given git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@645470 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/cpp/src/qpid/broker/PreviewConnectionCodec.cpp3
-rw-r--r--qpid/cpp/src/qpid/sys/AsynchIOAcceptor.cpp2
2 files changed, 3 insertions, 2 deletions
diff --git a/qpid/cpp/src/qpid/broker/PreviewConnectionCodec.cpp b/qpid/cpp/src/qpid/broker/PreviewConnectionCodec.cpp
index d3a5281109..b6c9b03776 100644
--- a/qpid/cpp/src/qpid/broker/PreviewConnectionCodec.cpp
+++ b/qpid/cpp/src/qpid/broker/PreviewConnectionCodec.cpp
@@ -40,7 +40,7 @@ size_t PreviewConnectionCodec::decode(const char* buffer, size_t size) {
}
bool PreviewConnectionCodec::canEncode() {
- if (!frameQueueClosed) connection.doOutput();
+ if (!frameQueueClosed && frameQueue.empty()) connection.doOutput();
return !frameQueue.empty();
}
@@ -56,6 +56,7 @@ size_t PreviewConnectionCodec::encode(const char* buffer, size_t size) {
frameQueue.front().encode(out);
QPID_LOG(trace, "SENT [" << identifier << "]: " << frameQueue.front());
frameQueue.pop();
+ if (!frameQueueClosed && frameQueue.empty()) connection.doOutput();
}
if (!frameQueue.empty() && frameQueue.front().size() > size)
throw framing::ContentTooLargeException(QPID_MSG("Could not write frame, too large for buffer."));
diff --git a/qpid/cpp/src/qpid/sys/AsynchIOAcceptor.cpp b/qpid/cpp/src/qpid/sys/AsynchIOAcceptor.cpp
index 6502885ed0..153557c5e5 100644
--- a/qpid/cpp/src/qpid/sys/AsynchIOAcceptor.cpp
+++ b/qpid/cpp/src/qpid/sys/AsynchIOAcceptor.cpp
@@ -301,7 +301,7 @@ void AsynchIOHandler::idle(AsynchIO&){
return;
}
if (codec == 0) return;
- while (codec->canEncode()) {
+ if (codec->canEncode()) {
// Try and get a queued buffer if not then construct new one
AsynchIO::BufferBase* buff = aio->getQueuedBuffer();
if (!buff) buff = new Buff;