vom: Fix connection to VAPI and add disconnect function
Change-Id: I2dd5dbafe36e5ae536b3e600beb6920a71238b7a Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
This commit is contained in:
Mohsin Kazmi
committed by
Neale Ranns
parent
3fca567ff4
commit
18e955ea8a
@ -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&
|
||||
|
@ -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
|
||||
|
@ -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 <>
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user