Make timer system use boost

The original crow timeout system had a timer queue setup for handling
many thousands of connections at a time efficiently.  The most common
use cases for the bmc involve a handful of connections, so this code
doesn't help us much.

These days, boost asio also implements a very similar timer queue
https://www.boost.org/doc/libs/1_72_0/boost/asio/detail/timer_queue.hpp
internally, so the only thing we're loosing here is the "fuzzy"
coalescing of timeout actions, for which it's tough to say if anyone
will even notice.

This commit implements a timer system that's self contained within each
connection, using steady_timer.  This is much more "normal" and how most
of the beast examples implement timers.

Tested:
Minimal touch testing to ensure that things work, but more testing is
required, probably using sloworis to ensure that our timeouts are no
longer issues.

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I19156411ce46adff6c88ad97ee8f6af8c858fe3c
diff --git a/http/http_server.hpp b/http/http_server.hpp
index 20b4e50..4037789 100644
--- a/http/http_server.hpp
+++ b/http/http_server.hpp
@@ -2,7 +2,6 @@
 
 #include "http_connection.hpp"
 #include "logging.hpp"
-#include "timer_queue.hpp"
 
 #include <boost/asio/ip/address.hpp>
 #include <boost/asio/ip/tcp.hpp>
@@ -36,8 +35,8 @@
                std::make_shared<boost::asio::io_context>()) :
         ioService(std::move(io)),
         acceptor(std::move(acceptorIn)),
-        signals(*ioService, SIGINT, SIGTERM, SIGHUP), timer(*ioService),
-        handler(handlerIn), adaptorCtx(std::move(adaptorCtx))
+        signals(*ioService, SIGINT, SIGTERM, SIGHUP), handler(handlerIn),
+        adaptorCtx(std::move(adaptorCtx))
     {}
 
     Server(Handler* handlerIn, const std::string& bindaddr, uint16_t port,
@@ -91,19 +90,6 @@
             return this->dateStr;
         };
 
-        timer.expires_after(std::chrono::seconds(1));
-
-        timerHandler = [this](const boost::system::error_code& ec) {
-            if (ec)
-            {
-                return;
-            }
-            timerQueue.process();
-            timer.expires_after(std::chrono::seconds(1));
-            timer.async_wait(timerHandler);
-        };
-        timer.async_wait(timerHandler);
-
         BMCWEB_LOG_INFO << "bmcweb server is running, local endpoint "
                         << acceptor->local_endpoint();
         startAsyncWaitForSignal();
@@ -179,13 +165,14 @@
     void doAccept()
     {
         std::optional<Adaptor> adaptorTemp;
+        boost::asio::steady_timer timer(*ioService);
         if constexpr (std::is_same<Adaptor,
                                    boost::beast::ssl_stream<
                                        boost::asio::ip::tcp::socket>>::value)
         {
             adaptorTemp = Adaptor(*ioService, *adaptorCtx);
             auto p = std::make_shared<Connection<Adaptor, Handler>>(
-                handler, getCachedDateStr, timerQueue,
+                handler, std::move(timer), getCachedDateStr,
                 std::move(adaptorTemp.value()));
 
             acceptor->async_accept(p->socket().next_layer(),
@@ -203,7 +190,7 @@
         {
             adaptorTemp = Adaptor(*ioService);
             auto p = std::make_shared<Connection<Adaptor, Handler>>(
-                handler, getCachedDateStr, timerQueue,
+                handler, std::move(timer), getCachedDateStr,
                 std::move(adaptorTemp.value()));
 
             acceptor->async_accept(
@@ -220,21 +207,17 @@
 
   private:
     std::shared_ptr<boost::asio::io_context> ioService;
-    detail::TimerQueue timerQueue;
     std::function<std::string()> getCachedDateStr;
     std::unique_ptr<boost::asio::ip::tcp::acceptor> acceptor;
     boost::asio::signal_set signals;
-    boost::asio::steady_timer timer;
 
     std::string dateStr;
 
     Handler* handler;
 
-    std::function<void(const boost::system::error_code& ec)> timerHandler;
-
 #ifdef BMCWEB_ENABLE_SSL
     bool useSsl{false};
 #endif
     std::shared_ptr<boost::asio::ssl::context> adaptorCtx;
-}; // namespace crow
+};
 } // namespace crow