From 3d3fb015b49b088a6e1f641437cd6b7acb0ed6ec Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Tue, 22 Sep 2009 15:59:53 +0000 Subject: Make the AsynchIO API more consistent git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@817711 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/sys/AsynchIO.h | 2 +- cpp/src/qpid/sys/AsynchIOHandler.cpp | 8 ++------ cpp/src/qpid/sys/AsynchIOHandler.h | 2 +- cpp/src/qpid/sys/posix/AsynchIO.cpp | 3 ++- cpp/src/qpid/sys/windows/AsynchIO.cpp | 2 +- 5 files changed, 7 insertions(+), 10 deletions(-) (limited to 'cpp/src') diff --git a/cpp/src/qpid/sys/AsynchIO.h b/cpp/src/qpid/sys/AsynchIO.h index fb02183359..193d41aceb 100644 --- a/cpp/src/qpid/sys/AsynchIO.h +++ b/cpp/src/qpid/sys/AsynchIO.h @@ -108,7 +108,7 @@ class AsynchIO { public: typedef AsynchIOBufferBase BufferBase; - typedef boost::function2 ReadCallback; + typedef boost::function2 ReadCallback; typedef boost::function1 EofCallback; typedef boost::function1 DisconnectCallback; typedef boost::function2 ClosedCallback; diff --git a/cpp/src/qpid/sys/AsynchIOHandler.cpp b/cpp/src/qpid/sys/AsynchIOHandler.cpp index 46d8f3b4f1..ae41eacfc3 100644 --- a/cpp/src/qpid/sys/AsynchIOHandler.cpp +++ b/cpp/src/qpid/sys/AsynchIOHandler.cpp @@ -103,13 +103,11 @@ void AsynchIOHandler::giveReadCredit(int32_t credit) { aio->startReading(); } -bool AsynchIOHandler::readbuff(AsynchIO& , AsynchIO::BufferBase* buff) { +void AsynchIOHandler::readbuff(AsynchIO& , AsynchIO::BufferBase* buff) { if (readError) { - return false; + return; } - bool ret = true; - // Check here for read credit if (readCredit.get() != InfiniteCredit) { // TODO In theory should be able to use an atomic operation before taking the lock @@ -119,7 +117,6 @@ bool AsynchIOHandler::readbuff(AsynchIO& , AsynchIO::BufferBase* buff) { assert(readCredit.get() >= 0); if (readCredit.get() == 0) { aio->stopReading(); - ret = false; } } } @@ -166,7 +163,6 @@ bool AsynchIOHandler::readbuff(AsynchIO& , AsynchIO::BufferBase* buff) { // Give whole buffer back to aio subsystem aio->queueReadBuffer(buff); } - return ret; } void AsynchIOHandler::eof(AsynchIO&) { diff --git a/cpp/src/qpid/sys/AsynchIOHandler.h b/cpp/src/qpid/sys/AsynchIOHandler.h index 9785f445a4..e1885bac79 100644 --- a/cpp/src/qpid/sys/AsynchIOHandler.h +++ b/cpp/src/qpid/sys/AsynchIOHandler.h @@ -65,7 +65,7 @@ class AsynchIOHandler : public OutputControl { QPID_COMMON_EXTERN void giveReadCredit(int32_t credit); // Input side - QPID_COMMON_EXTERN bool readbuff(AsynchIO& aio, AsynchIOBufferBase* buff); + QPID_COMMON_EXTERN void readbuff(AsynchIO& aio, AsynchIOBufferBase* buff); QPID_COMMON_EXTERN void eof(AsynchIO& aio); QPID_COMMON_EXTERN void disconnect(AsynchIO& aio); diff --git a/cpp/src/qpid/sys/posix/AsynchIO.cpp b/cpp/src/qpid/sys/posix/AsynchIO.cpp index 8545ebd9cb..c6d73b059e 100644 --- a/cpp/src/qpid/sys/posix/AsynchIO.cpp +++ b/cpp/src/qpid/sys/posix/AsynchIO.cpp @@ -467,7 +467,8 @@ void AsynchIO::readable(DispatchHandle& h) { threadReadTotal += rc; readTotal += rc; - if (!readCallback(*this, buff)) { + readCallback(*this, buff); + if (readingStopped) { // We have been flow controlled. break; } diff --git a/cpp/src/qpid/sys/windows/AsynchIO.cpp b/cpp/src/qpid/sys/windows/AsynchIO.cpp index 8905b87838..475b18600d 100644 --- a/cpp/src/qpid/sys/windows/AsynchIO.cpp +++ b/cpp/src/qpid/sys/windows/AsynchIO.cpp @@ -634,7 +634,7 @@ void AsynchIO::readComplete(AsynchReadResult *result) { if (status == 0 && bytes > 0) { bool restartRead = true; // May not if receiver doesn't want more if (readCallback) - restartRead = readCallback(*this, result->getBuff()); + readCallback(*this, result->getBuff()); if (restartRead) startReading(); } -- cgit v1.2.1