aboutsummaryrefslogtreecommitdiffstats
path: root/src/vpp-api
diff options
context:
space:
mode:
authorMohsin Kazmi <sykazmi@cisco.com>2018-01-08 12:58:32 +0100
committerNeale Ranns <nranns@cisco.com>2018-01-22 20:15:36 +0000
commit18e955ea8a90b691294d71c0772770c88fadc062 (patch)
treef3213078f721af7881c979b0d296d63e792c841f /src/vpp-api
parent3fca567ff438145e28dd1318ad5b1734c1091257 (diff)
vom: Fix connection to VAPI and add disconnect function
Change-Id: I2dd5dbafe36e5ae536b3e600beb6920a71238b7a Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
Diffstat (limited to 'src/vpp-api')
-rw-r--r--src/vpp-api/vom/connection.cpp12
-rw-r--r--src/vpp-api/vom/connection.hpp2
-rw-r--r--src/vpp-api/vom/hw.cpp44
-rw-r--r--src/vpp-api/vom/hw.hpp14
-rw-r--r--src/vpp-api/vom/route.cpp2
-rw-r--r--src/vpp-api/vom/tap_interface.cpp2
6 files changed, 48 insertions, 28 deletions
diff --git a/src/vpp-api/vom/connection.cpp b/src/vpp-api/vom/connection.cpp
index 90c02f943c4..c03ef99c172 100644
--- a/src/vpp-api/vom/connection.cpp
+++ b/src/vpp-api/vom/connection.cpp
@@ -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&
diff --git a/src/vpp-api/vom/connection.hpp b/src/vpp-api/vom/connection.hpp
index c8acf78cca5..06fe840232d 100644
--- a/src/vpp-api/vom/connection.hpp
+++ b/src/vpp-api/vom/connection.hpp
@@ -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
diff --git a/src/vpp-api/vom/hw.cpp b/src/vpp-api/vom/hw.cpp
index 91faf9d4db0..8f64a75c092 100644
--- a/src/vpp-api/vom/hw.cpp
+++ b/src/vpp-api/vom/hw.cpp
@@ -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 <>
diff --git a/src/vpp-api/vom/hw.hpp b/src/vpp-api/vom/hw.hpp
index 903aa78fb25..9ba47505619 100644
--- a/src/vpp-api/vom/hw.hpp
+++ b/src/vpp-api/vom/hw.hpp
@@ -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
diff --git a/src/vpp-api/vom/route.cpp b/src/vpp-api/vom/route.cpp
index 78ea8cebfad..a0474676ee6 100644
--- a/src/vpp-api/vom/route.cpp
+++ b/src/vpp-api/vom/route.cpp
@@ -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
diff --git a/src/vpp-api/vom/tap_interface.cpp b/src/vpp-api/vom/tap_interface.cpp
index 1f85ca11507..d7f16f5c132 100644
--- a/src/vpp-api/vom/tap_interface.cpp
+++ b/src/vpp-api/vom/tap_interface.cpp
@@ -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