this, true),
TEST_TIMEOUT, IntervalTimer::ONE_SHOT);
// Run until the client stops the service or an error occurs.
- io_service->run();
+ try {
+ io_service->run();
+ } catch (...) {
+ }
test_timer.cancel();
if (io_service->stopped()) {
io_service->restart();
this, true),
TEST_TIMEOUT, IntervalTimer::ONE_SHOT);
// Run until the client stops the service or an error occurs.
- io_service->run();
+ try {
+ io_service->run();
+ } catch (...) {
+ }
test_timer.cancel();
if (io_service->stopped()) {
io_service->restart();
HttpConnection::HttpConnection(const asiolink::IOServicePtr& io_service,
const HttpAcceptorPtr& acceptor,
const TlsContextPtr& tls_context,
- HttpConnectionPool& connection_pool,
+ HttpConnectionPoolPtr connection_pool,
const HttpResponseCreatorPtr& response_creator,
const HttpAcceptorCallback& callback,
const long request_timeout,
void
HttpConnection::shutdownConnection() {
+ auto connection_pool = connection_pool_.lock();
try {
LOG_DEBUG(http_logger, isc::log::DBGLVL_TRACE_BASIC,
HTTP_CONNECTION_SHUTDOWN)
.arg(getRemoteEndpointAddressAsText());
- connection_pool_.shutdown(shared_from_this());
+ if (connection_pool) {
+ connection_pool->shutdown(shared_from_this());
+ } else {
+ shutdown();
+ }
} catch (...) {
LOG_ERROR(http_logger, HTTP_CONNECTION_SHUTDOWN_FAILED);
}
void
HttpConnection::stopThisConnection() {
+ auto connection_pool = connection_pool_.lock();
try {
LOG_DEBUG(http_logger, isc::log::DBGLVL_TRACE_BASIC,
HTTP_CONNECTION_STOP)
.arg(getRemoteEndpointAddressAsText());
- connection_pool_.stop(shared_from_this());
+ if (connection_pool) {
+ connection_pool->stop(shared_from_this());
+ } else {
+ close();
+ }
} catch (...) {
LOG_ERROR(http_logger, HTTP_CONNECTION_STOP_FAILED);
}
HttpConnection(const asiolink::IOServicePtr& io_service,
const HttpAcceptorPtr& acceptor,
const asiolink::TlsContextPtr& tls_context,
- HttpConnectionPool& connection_pool,
+ std::shared_ptr<HttpConnectionPool> connection_pool,
const HttpResponseCreatorPtr& response_creator,
const HttpAcceptorCallback& callback,
const long request_timeout,
HttpAcceptorPtr acceptor_;
/// @brief Connection pool holding this connection.
- HttpConnectionPool& connection_pool_;
+ std::weak_ptr<HttpConnectionPool> connection_pool_;
/// @brief Pointer to the @ref HttpResponseCreator object used to create
/// HTTP responses.
std::mutex mutex_;
};
+/// @brief Pointer to the @ref HttpConnection.
+typedef std::shared_ptr<HttpConnectionPool> HttpConnectionPoolPtr;
+
}
}
const long request_timeout,
const long idle_timeout)
: io_service_(io_service), tls_context_(tls_context), acceptor_(),
- endpoint_(), connections_(),
+ endpoint_(), connections_(new HttpConnectionPool()),
creator_factory_(creator_factory),
request_timeout_(request_timeout), idle_timeout_(idle_timeout),
use_external_(false) {
void
HttpListenerImpl::stop() {
- connections_.stopAll();
+ connections_->stopAll();
if (use_external_) {
IfaceMgr::instance().deleteExternalSocket(acceptor_->getNative());
}
conn->addExternalSockets(true);
}
// Add this new connection to the pool.
- connections_.start(conn);
+ connections_->start(conn);
}
void
boost::scoped_ptr<asiolink::TCPEndpoint> endpoint_;
/// @brief Pool of active connections.
- HttpConnectionPool connections_;
+ HttpConnectionPoolPtr connections_;
/// @brief Pointer to the @ref HttpResponseCreatorFactory.
HttpResponseCreatorFactoryPtr creator_factory_;
bool use_external_;
};
-
} // end of namespace isc::http
} // end of namespace isc
HttpConnectionPoolTest()
: io_service_(new IOService()),
acceptor_(new HttpAcceptor(io_service_)),
- connection_pool_(),
+ connection_pool_(new HttpConnectionPool()),
response_creator_(new TestHttpResponseCreator()) {
MultiThreadingMgr::instance().setMode(false);
}
IOServicePtr io_service_; ///< IO service.
HttpAcceptorPtr acceptor_; ///< Test acceptor.
- HttpConnectionPool connection_pool_; ///< Test connection pool.
+ HttpConnectionPoolPtr connection_pool_; ///< Test connection pool.
HttpResponseCreatorPtr response_creator_; ///< Test response creator.
};
HttpConnectionLongWriteBuffer(const IOServicePtr& io_service,
const HttpAcceptorPtr& acceptor,
const TlsContextPtr& tls_context,
- HttpConnectionPool& connection_pool,
+ HttpConnectionPoolPtr connection_pool,
const HttpResponseCreatorPtr& response_creator,
const HttpAcceptorCallback& callback,
const long request_timeout,
HttpConnectionTransactionChange(const IOServicePtr& io_service,
const HttpAcceptorPtr& acceptor,
const TlsContextPtr& tls_context,
- HttpConnectionPool& connection_pool,
+ HttpConnectionPoolPtr connection_pool,
const HttpResponseCreatorPtr& response_creator,
const HttpAcceptorCallback& callback,
const long request_timeout,