summaryrefslogtreecommitdiffstats
path: root/src/vpp-api/vom/hw.cpp
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/vom/hw.cpp
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/vom/hw.cpp')
-rw-r--r--src/vpp-api/vom/hw.cpp44
1 files changed, 28 insertions, 16 deletions
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 <>