vom: Fix connection to VAPI and add disconnect function 05/10105/3
authorMohsin Kazmi <sykazmi@cisco.com>
Mon, 8 Jan 2018 11:58:32 +0000 (12:58 +0100)
committerNeale Ranns <nranns@cisco.com>
Mon, 22 Jan 2018 20:15:36 +0000 (20:15 +0000)
Change-Id: I2dd5dbafe36e5ae536b3e600beb6920a71238b7a
Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
src/vpp-api/vom/connection.cpp
src/vpp-api/vom/connection.hpp
src/vpp-api/vom/hw.cpp
src/vpp-api/vom/hw.hpp
src/vpp-api/vom/route.cpp
src/vpp-api/vom/tap_interface.cpp

index 90c02f9..c03ef99 100644 (file)
@@ -26,7 +26,6 @@ connection::connection()
 
 connection::~connection()
 {
-  disconnect();
 }
 
 void
@@ -35,16 +34,15 @@ connection::disconnect()
   m_vapi_conn->disconnect();
 }
 
-void
+int
 connection::connect()
 {
   vapi_error_e rv;
 
-  do {
-    rv = m_vapi_conn->connect(m_app_name.c_str(),
-                              NULL, // m_api_prefix.c_str(),
-                              128, 128);
-  } while (VAPI_OK != rv);
+  rv = m_vapi_conn->connect(m_app_name.c_str(),
+                            NULL, // m_api_prefix.c_str(),
+                            128, 128);
+  return rv;
 }
 
 vapi::Connection&
index c8acf78..06fe840 100644 (file)
@@ -46,7 +46,7 @@ public:
    * Blocking [re]connect call - always eventually succeeds, or the
    * universe expires. Not much this system can do without one.
    */
-  void connect();
+  int connect();
 
   /**
    * Blocking disconnect
index 91faf9d..8f64a75 100644 (file)
@@ -27,11 +27,6 @@ HW::cmd_q::cmd_q()
 
 HW::cmd_q::~cmd_q()
 {
-  m_connected = false;
-
-  if (m_rx_thread && m_rx_thread->joinable()) {
-    m_rx_thread->join();
-  }
 }
 
 HW::cmd_q&
@@ -76,12 +71,27 @@ HW::cmd_q::enqueue(std::queue<cmd*>& cmds)
   }
 }
 
-void
+bool
 HW::cmd_q::connect()
 {
-  if (m_connected) {
-    m_conn.disconnect();
-  }
+  int rv;
+
+  if (m_connected)
+    return m_connected;
+
+  rv = m_conn.connect();
+
+  m_connected = true;
+  m_rx_thread.reset(new std::thread(&HW::cmd_q::rx_run, this));
+  return (rv == 0);
+}
+
+void
+HW::cmd_q::disconnect()
+{
+
+  if (!m_connected)
+    return;
 
   m_connected = false;
 
@@ -89,10 +99,7 @@ HW::cmd_q::connect()
     m_rx_thread->join();
   }
 
-  m_conn.connect();
-
-  m_connected = true;
-  m_rx_thread.reset(new std::thread(&HW::cmd_q::rx_run, this));
+  m_conn.disconnect();
 }
 
 void
@@ -203,10 +210,16 @@ HW::enqueue(std::queue<cmd*>& cmds)
   m_cmdQ->enqueue(cmds);
 }
 
-void
+bool
 HW::connect()
 {
-  m_cmdQ->connect();
+  return m_cmdQ->connect();
+}
+
+void
+HW::disconnect()
+{
+  m_cmdQ->disconnect();
 }
 
 void
@@ -236,7 +249,6 @@ HW::poll()
   HW::write();
 
   return (m_poll_state);
-  return (true);
 }
 
 template <>
index 903aa78..9ba4750 100644 (file)
@@ -222,7 +222,12 @@ public:
     /**
      * Blocking Connect to VPP - call once at bootup
      */
-    virtual void connect();
+    virtual bool connect();
+
+    /**
+     * Disconnect to VPP
+     */
+    virtual void disconnect();
 
     /**
      * Disable the passing of commands to VPP. Whilst disabled all
@@ -309,7 +314,12 @@ public:
   /**
    * Blocking Connect to VPP
    */
-  static void connect();
+  static bool connect();
+
+  /**
+   * Disconnect to VPP
+   */
+  static void disconnect();
 
   /**
    * Blocking pool of the HW connection
index 78ea8ce..a047467 100644 (file)
@@ -486,7 +486,7 @@ ip_route::event_handler::handle_populate(const client_db::key_t& key)
 dependency_t
 ip_route::event_handler::order() const
 {
-  return (dependency_t::BINDING);
+  return (dependency_t::ENTRY);
 }
 
 void
index 1f85ca1..d7f16f5 100644 (file)
@@ -125,7 +125,7 @@ tap_interface::event_handler::event_handler()
 void
 tap_interface::event_handler::handle_replay()
 {
-  m_db.replay();
+  // It will be replayed by interface handler
 }
 
 dependency_t