diff options
| author | Ted Ross <tross@apache.org> | 2008-05-21 21:40:49 +0000 |
|---|---|---|
| committer | Ted Ross <tross@apache.org> | 2008-05-21 21:40:49 +0000 |
| commit | 35d9dc572a918015c038245725b0f9894b13132a (patch) | |
| tree | d9efecaeab11e12f0b2f2d87ff7f202383eaa6a0 /cpp/src/qpid/sys/TCPIOPlugin.cpp | |
| parent | 28404c0026b5bed8ad4ad37d52cd4d3aab5c70bc (diff) | |
| download | qpid-python-35d9dc572a918015c038245725b0f9894b13132a.tar.gz | |
QPID-1087
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@658886 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/sys/TCPIOPlugin.cpp')
| -rw-r--r-- | cpp/src/qpid/sys/TCPIOPlugin.cpp | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/cpp/src/qpid/sys/TCPIOPlugin.cpp b/cpp/src/qpid/sys/TCPIOPlugin.cpp index 5d2cadbe03..e82a6a9102 100644 --- a/cpp/src/qpid/sys/TCPIOPlugin.cpp +++ b/cpp/src/qpid/sys/TCPIOPlugin.cpp @@ -42,14 +42,15 @@ class AsynchIOProtocolFactory : public ProtocolFactory { AsynchIOProtocolFactory(int16_t port, int backlog); void accept(Poller::shared_ptr, ConnectionCodec::Factory*); void connect(Poller::shared_ptr, const std::string& host, int16_t port, - ConnectionCodec::Factory*, ProtocolAccess*); + ConnectionCodec::Factory*, + boost::function2<void, int, std::string> failed); uint16_t getPort() const; std::string getHost() const; private: void established(Poller::shared_ptr, const Socket&, ConnectionCodec::Factory*, - bool isClient, ProtocolAccess*); + bool isClient); }; // Static instance to initialise plugin @@ -74,31 +75,18 @@ AsynchIOProtocolFactory::AsynchIOProtocolFactory(int16_t port, int backlog) : {} void AsynchIOProtocolFactory::established(Poller::shared_ptr poller, const Socket& s, - ConnectionCodec::Factory* f, bool isClient, - ProtocolAccess* a) { - AsynchIOHandler* async = new AsynchIOHandler(s.getPeerAddress(), f, a); - AsynchIO* aio; + ConnectionCodec::Factory* f, bool isClient) { + AsynchIOHandler* async = new AsynchIOHandler(s.getPeerAddress(), f); if (isClient) async->setClient(); - if (a == 0) - aio = new AsynchIO(s, - boost::bind(&AsynchIOHandler::readbuff, async, _1, _2), - boost::bind(&AsynchIOHandler::eof, async, _1), - boost::bind(&AsynchIOHandler::disconnect, async, _1), - boost::bind(&AsynchIOHandler::closedSocket, async, _1, _2), - boost::bind(&AsynchIOHandler::nobuffs, async, _1), - boost::bind(&AsynchIOHandler::idle, async, _1)); - else { - aio = new AsynchIO(s, - boost::bind(&AsynchIOHandler::readbuff, async, _1, _2), - boost::bind(&ProtocolAccess::closedEof, a, async), - boost::bind(&AsynchIOHandler::disconnect, async, _1), - boost::bind(&AsynchIOHandler::closedSocket, async, _1, _2), - boost::bind(&AsynchIOHandler::nobuffs, async, _1), - boost::bind(&AsynchIOHandler::idle, async, _1)); - a->setAio(aio); - } + AsynchIO* aio = new AsynchIO(s, + boost::bind(&AsynchIOHandler::readbuff, async, _1, _2), + boost::bind(&AsynchIOHandler::eof, async, _1), + boost::bind(&AsynchIOHandler::disconnect, async, _1), + boost::bind(&AsynchIOHandler::closedSocket, async, _1, _2), + boost::bind(&AsynchIOHandler::nobuffs, async, _1), + boost::bind(&AsynchIOHandler::idle, async, _1)); async->init(aio, 4); aio->start(poller); @@ -116,8 +104,7 @@ void AsynchIOProtocolFactory::accept(Poller::shared_ptr poller, ConnectionCodec::Factory* fact) { acceptor.reset( new AsynchAcceptor(listener, - boost::bind(&AsynchIOProtocolFactory::established, this, poller, _1, fact, false, - (ProtocolAccess*) 0))); + boost::bind(&AsynchIOProtocolFactory::established, this, poller, _1, fact, false))); acceptor->start(poller); } @@ -125,7 +112,7 @@ void AsynchIOProtocolFactory::connect( Poller::shared_ptr poller, const std::string& host, int16_t port, ConnectionCodec::Factory* fact, - ProtocolAccess* access) + boost::function2<void, int, std::string> failed) { // Note that the following logic does not cause a memory leak. // The allocated Socket is freed either by the AsynchConnector @@ -135,8 +122,8 @@ void AsynchIOProtocolFactory::connect( Socket* socket = new Socket(); new AsynchConnector (*socket, poller, host, port, - boost::bind(&AsynchIOProtocolFactory::established, this, poller, _1, fact, true, access), - boost::bind(&ProtocolAccess::closed, access, _1, _2)); + boost::bind(&AsynchIOProtocolFactory::established, this, poller, _1, fact, true), + failed); } }} // namespace qpid::sys |
