vom: Fix connection to VAPI and add disconnect function
Change-Id: I2dd5dbafe36e5ae536b3e600beb6920a71238b7a
Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
diff --git a/src/vpp-api/vom/connection.cpp b/src/vpp-api/vom/connection.cpp
index 90c02f9..c03ef99 100644
--- a/src/vpp-api/vom/connection.cpp
+++ b/src/vpp-api/vom/connection.cpp
@@ -26,7 +26,6 @@
connection::~connection()
{
- disconnect();
}
void
@@ -35,16 +34,15 @@
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&
diff --git a/src/vpp-api/vom/connection.hpp b/src/vpp-api/vom/connection.hpp
index c8acf78..06fe840 100644
--- a/src/vpp-api/vom/connection.hpp
+++ b/src/vpp-api/vom/connection.hpp
@@ -46,7 +46,7 @@
* 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
diff --git a/src/vpp-api/vom/hw.cpp b/src/vpp-api/vom/hw.cpp
index 91faf9d..8f64a75 100644
--- a/src/vpp-api/vom/hw.cpp
+++ b/src/vpp-api/vom/hw.cpp
@@ -27,11 +27,6 @@
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 @@
}
}
-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 @@
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 @@
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::write();
return (m_poll_state);
- return (true);
}
template <>
diff --git a/src/vpp-api/vom/hw.hpp b/src/vpp-api/vom/hw.hpp
index 903aa78..9ba4750 100644
--- a/src/vpp-api/vom/hw.hpp
+++ b/src/vpp-api/vom/hw.hpp
@@ -222,7 +222,12 @@
/**
* 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 @@
/**
* Blocking Connect to VPP
*/
- static void connect();
+ static bool connect();
+
+ /**
+ * Disconnect to VPP
+ */
+ static void disconnect();
/**
* Blocking pool of the HW connection
diff --git a/src/vpp-api/vom/route.cpp b/src/vpp-api/vom/route.cpp
index 78ea8ce..a047467 100644
--- a/src/vpp-api/vom/route.cpp
+++ b/src/vpp-api/vom/route.cpp
@@ -486,7 +486,7 @@
dependency_t
ip_route::event_handler::order() const
{
- return (dependency_t::BINDING);
+ return (dependency_t::ENTRY);
}
void
diff --git a/src/vpp-api/vom/tap_interface.cpp b/src/vpp-api/vom/tap_interface.cpp
index 1f85ca1..d7f16f5 100644
--- a/src/vpp-api/vom/tap_interface.cpp
+++ b/src/vpp-api/vom/tap_interface.cpp
@@ -125,7 +125,7 @@
void
tap_interface::event_handler::handle_replay()
{
- m_db.replay();
+ // It will be replayed by interface handler
}
dependency_t