Make timer a member variable

Having non const global variables is an anti-pattern.  Given that this
timer is channel specific, we really should have a timer per channel.

Change-Id: I91388571c4718e7ebdbf6cdb878307fb03a5327b
Signed-off-by: Ed Tanous <ed@tanous.net>
diff --git a/ssifbridged.cpp b/ssifbridged.cpp
index dd1533c..5ac0eed 100644
--- a/ssifbridged.cpp
+++ b/ssifbridged.cpp
@@ -91,9 +91,10 @@
      * not processed properly
      * */
     int numberOfReqNotRsp;
+
+    boost::asio::steady_timer rspTimer;
 };
 
-std::unique_ptr<boost::asio::steady_timer> rspTimer;
 std::unique_ptr<SsifChannel> ssifchannel = nullptr;
 
 SsifChannel::SsifChannel(std::shared_ptr<boost::asio::io_context>& io,
@@ -101,7 +102,8 @@
                          const std::string& device, bool verbose,
                          int numberOfReqNotRsp) :
     io(io),
-    bus(bus), verbose(verbose), numberOfReqNotRsp(numberOfReqNotRsp)
+    bus(bus), verbose(verbose), numberOfReqNotRsp(numberOfReqNotRsp),
+    rspTimer(*io)
 {
     std::string devName = devBase;
     if (!device.empty())
@@ -203,14 +205,6 @@
     }
 }
 
-void initTimer(boost::asio::io_context& io)
-{
-    if (!rspTimer)
-    {
-        rspTimer = std::make_unique<boost::asio::steady_timer>(io);
-    }
-}
-
 void SsifChannel::processMessage(const boost::system::error_code& ecRd,
                                  size_t rlen)
 {
@@ -235,8 +229,8 @@
     /* there is a request coming */
     numberOfReqNotRsp++;
     /* start response timer */
-    rspTimer->expires_after(std::chrono::microseconds(hostReqTimeout));
-    rspTimer->async_wait(rspTimerHandler);
+    rspTimer.expires_after(std::chrono::microseconds(hostReqTimeout));
+    rspTimer.async_wait(rspTimerHandler);
 
     if (verbose)
     {
@@ -363,7 +357,7 @@
                 " cc=" + std::to_string(cc);
             log<level::ERR>(msgToLog.c_str());
         }
-        rspTimer->cancel();
+        rspTimer.cancel();
     },
         ipmiQueueService, ipmiQueuePath, ipmiQueueIntf, ipmiQueueMethod,
         dbusTimeout, netfn, lun, cmd, data, options);
@@ -391,7 +385,6 @@
     {
         return EXIT_FAILURE;
     }
-    initTimer(*io);
     io->run();
 
     return 0;