summaryrefslogtreecommitdiffstats
path: root/http/http_server.h
diff options
context:
space:
mode:
Diffstat (limited to 'http/http_server.h')
-rw-r--r--http/http_server.h25
1 files changed, 16 insertions, 9 deletions
diff --git a/http/http_server.h b/http/http_server.h
index 6e63cbd..df42214 100644
--- a/http/http_server.h
+++ b/http/http_server.h
@@ -44,8 +44,7 @@ class Server
ioService(std::move(io)),
acceptor(std::move(acceptor)),
signals(*ioService, SIGINT, SIGTERM, SIGHUP), tickTimer(*ioService),
- timer(*ioService), handler(handler), middlewares(middlewares),
- adaptorCtx(adaptor_ctx)
+ handler(handler), middlewares(middlewares), adaptorCtx(adaptor_ctx)
{
}
@@ -124,9 +123,11 @@ class Server
return this->dateStr;
};
+ boost::asio::steady_timer timer(*ioService);
timer.expires_after(std::chrono::seconds(1));
- timerHandler = [this](const boost::system::error_code& ec) {
+ std::function<void(const boost::system::error_code& ec)> timerHandler;
+ timerHandler = [&](const boost::system::error_code& ec) {
if (ec)
{
return;
@@ -230,8 +231,8 @@ class Server
boost::asio::ip::tcp::socket>>::value)
{
adaptorTemp = Adaptor(*ioService, *adaptorCtx);
- auto p =
- std::make_shared<Connection<Adaptor, Handler, Middlewares...>>(
+ Connection<Adaptor, Handler, Middlewares...>* p =
+ new Connection<Adaptor, Handler, Middlewares...>(
*ioService, handler, serverName, middlewares,
getCachedDateStr, timerQueue,
std::move(adaptorTemp.value()));
@@ -244,14 +245,18 @@ class Server
*this->ioService,
[p] { p->start(); });
}
+ else
+ {
+ delete p;
+ }
doAccept();
});
}
else
{
adaptorTemp = Adaptor(*ioService);
- auto p =
- std::make_shared<Connection<Adaptor, Handler, Middlewares...>>(
+ Connection<Adaptor, Handler, Middlewares...>* p =
+ new Connection<Adaptor, Handler, Middlewares...>(
*ioService, handler, serverName, middlewares,
getCachedDateStr, timerQueue,
std::move(adaptorTemp.value()));
@@ -263,6 +268,10 @@ class Server
boost::asio::post(*this->ioService,
[p] { p->start(); });
}
+ else
+ {
+ delete p;
+ }
doAccept();
});
}
@@ -275,7 +284,6 @@ class Server
std::unique_ptr<tcp::acceptor> acceptor;
boost::asio::signal_set signals;
boost::asio::steady_timer tickTimer;
- boost::asio::steady_timer timer;
std::string dateStr;
@@ -284,7 +292,6 @@ class Server
std::chrono::milliseconds tickInterval{};
std::function<void()> tickFunction;
- std::function<void(const boost::system::error_code& ec)> timerHandler;
std::tuple<Middlewares...>* middlewares;
OpenPOWER on IntegriCloud