From a7cf88ae2d7d5619cf4cb8eead6e4c9a4e1d62b1 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Mon, 21 May 2012 23:18:50 +0000 Subject: QPID-2518: Qpid C++ broker can easily be blocked by client trying to connect over SSL port Implement timed disconnect for TCP and for SSL/TCP mux git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1341262 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/sys/TCPIOPlugin.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'cpp/src/qpid/sys/TCPIOPlugin.cpp') diff --git a/cpp/src/qpid/sys/TCPIOPlugin.cpp b/cpp/src/qpid/sys/TCPIOPlugin.cpp index bd10a5555a..551440f954 100644 --- a/cpp/src/qpid/sys/TCPIOPlugin.cpp +++ b/cpp/src/qpid/sys/TCPIOPlugin.cpp @@ -36,14 +36,21 @@ namespace qpid { namespace sys { +class Timer; + class AsynchIOProtocolFactory : public ProtocolFactory { - const bool tcpNoDelay; boost::ptr_vector listeners; boost::ptr_vector acceptors; + Timer& brokerTimer; + uint32_t maxNegotiateTime; uint16_t listeningPort; + const bool tcpNoDelay; public: - AsynchIOProtocolFactory(const std::string& host, const std::string& port, int backlog, bool nodelay, bool shouldListen); + AsynchIOProtocolFactory(const std::string& host, const std::string& port, + int backlog, bool nodelay, + Timer& timer, uint32_t maxTime, + bool shouldListen); void accept(Poller::shared_ptr, ConnectionCodec::Factory*); void connect(Poller::shared_ptr, const std::string& host, const std::string& port, ConnectionCodec::Factory*, @@ -90,6 +97,7 @@ static class TCPIOPlugin : public Plugin { "", boost::lexical_cast(opts.port), opts.connectionBacklog, opts.tcpNoDelay, + broker->getTimer(), opts.maxNegotiateTime, shouldListen)); if (shouldListen) { @@ -101,7 +109,12 @@ static class TCPIOPlugin : public Plugin { } } tcpPlugin; -AsynchIOProtocolFactory::AsynchIOProtocolFactory(const std::string& host, const std::string& port, int backlog, bool nodelay, bool shouldListen) : +AsynchIOProtocolFactory::AsynchIOProtocolFactory(const std::string& host, const std::string& port, + int backlog, bool nodelay, + Timer& timer, uint32_t maxTime, + bool shouldListen) : + brokerTimer(timer), + maxNegotiateTime(maxTime), tcpNoDelay(nodelay) { if (!shouldListen) { @@ -153,7 +166,7 @@ void AsynchIOProtocolFactory::established(Poller::shared_ptr poller, const Socke boost::bind(&AsynchIOHandler::nobuffs, async, _1), boost::bind(&AsynchIOHandler::idle, async, _1)); - async->init(aio, 4); + async->init(aio, brokerTimer, maxNegotiateTime, 4); aio->start(poller); } -- cgit v1.2.1