libkea_http_la_LDFLAGS = $(AM_LDFLAGS)
libkea_http_la_LDFLAGS += -no-undefined -version-info 81:0:0
-libkea_http_la_LIBADD = $(top_builddir)/src/lib/hooks/libkea-hooks.la
+libkea_http_la_LIBADD = $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
+libkea_http_la_LIBADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
libkea_http_la_LIBADD += $(top_builddir)/src/lib/cc/libkea-cc.la
libkea_http_la_LIBADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
libkea_http_la_LIBADD += $(top_builddir)/src/lib/log/libkea-log.la
acceptor_(acceptor),
connection_pool_(connection_pool),
response_creator_(response_creator),
- acceptor_callback_(callback) {
+ acceptor_callback_(callback),
+ use_external_(false) {
if (!tls_context) {
tcp_socket_.reset(new asiolink::TCPSocket<SocketCallback>(io_service));
} else {
close();
}
+void
+HttpConnection::addExternalSockets(bool use_external) {
+ use_external_ = use_external;
+}
+
void
HttpConnection::recordParameters(const HttpRequestPtr& request) const {
if (!request) {
/// Closes current connection.
virtual ~HttpConnection();
+ /// @brief Use external sockets flag.
+ ///
+ /// Add sockets as external sockets of the interface manager
+ /// so available I/O on them makes a waiting select to return.
+ ///
+ /// @param use_external True add external sockets (default false).
+ void addExternalSockets(bool use_external = false);
+
/// @brief Asynchronously accepts new connection.
///
/// When the connection is established successfully, the timeout timer is
/// @brief External TCP acceptor callback.
HttpAcceptorCallback acceptor_callback_;
+
+ /// @brief Use external sockets flag.
+ bool use_external_;
};
} // end of namespace isc::http
return (impl_->getNative());
}
+void
+HttpListener::addExternalSockets(bool use_external) {
+ impl_->addExternalSockets(use_external);
+}
+
void
HttpListener::start() {
impl_->start();
/// @brief file descriptor of the underlying acceptor socket.
int getNative() const;
+ /// @brief Use external sockets flag.
+ ///
+ /// Add sockets as external sockets of the interface manager
+ /// so available I/O on them makes a waiting select to return.
+ ///
+ /// @param use_external True add external sockets (default false).
+ void addExternalSockets(bool use_external = false);
+
/// @brief Starts accepting new connections.
///
/// This method starts accepting and handling new HTTP connections on
#include <config.h>
#include <asiolink/asio_wrapper.h>
+#include <dhcp/iface_mgr.h>
#include <http/connection_pool.h>
#include <http/listener.h>
#include <http/listener_impl.h>
using namespace isc::asiolink;
+using namespace isc::dhcp;
namespace ph = std::placeholders;
namespace isc {
: io_service_(io_service), tls_context_(tls_context), acceptor_(),
endpoint_(), connections_(),
creator_factory_(creator_factory),
- request_timeout_(request_timeout), idle_timeout_(idle_timeout) {
+ request_timeout_(request_timeout), idle_timeout_(idle_timeout),
+ use_external_(false) {
// Create the TCP or TLS acceptor.
if (!tls_context) {
acceptor_.reset(new HttpAcceptor(io_service));
return (acceptor_ ? acceptor_->getNative() : -1);
}
+void
+HttpListenerImpl::addExternalSockets(bool use_external) {
+ use_external_ = use_external;
+}
+
void
HttpListenerImpl::start() {
try {
acceptor_->open(*endpoint_);
+ if (use_external_) {
+ IfaceMgr::instance().addExternalSocket(acceptor_->getNative(), 0);
+ }
acceptor_->setOption(HttpAcceptor::ReuseAddress(true));
acceptor_->bind(*endpoint_);
acceptor_->listen();
void
HttpListenerImpl::stop() {
connections_.stopAll();
+ if (use_external_) {
+ IfaceMgr::instance().deleteExternalSocket(acceptor_->getNative());
+ }
acceptor_->close();
}
std::bind(&HttpListenerImpl::acceptHandler, this, ph::_1);
HttpConnectionPtr conn = createConnection(response_creator,
acceptor_callback);
+ // Transmit the use external sockets flag.
+ if (use_external_) {
+ conn->addExternalSockets(true);
+ }
// Add this new connection to the pool.
connections_.start(conn);
}
/// @brief file descriptor of the underlying acceptor socket.
int getNative() const;
+ /// @brief Use external sockets flag.
+ ///
+ /// Add sockets as external sockets of the interface manager
+ /// so available I/O on them makes a waiting select to return.
+ ///
+ /// @param use_external True add external sockets.
+ void addExternalSockets(bool use_external);
+
/// @brief Starts accepting new connections.
///
/// This method starts accepting and handling new HTTP connections on
/// @brief Timeout after which idle persistent connection is closed by
/// the server.
long idle_timeout_;
+
+ /// @brief Use external sockets flag.
+ bool use_external_;
};
libhttp_unittests_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS) $(GTEST_LDFLAGS)
libhttp_unittests_LDADD = $(top_builddir)/src/lib/http/libkea-http.la
+libhttp_unittests_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
libhttp_unittests_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
libhttp_unittests_LDADD += $(top_builddir)/src/lib/testutils/libkea-testutils.la
libhttp_unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la
// Simulate receiving HTTP request in chunks.
for (size_t i = 0; i < http_req.size(); i += http_req.size() / 10) {
bool done = false;
- // Get the size of the data chunk.
+ // Get the size of the data chunk.
size_t chunk = http_req.size() / 10;
// When we're near the end of the data stream, the chunk length may
// vary.