Now only unwiring if the NDP proxy did the wiring in the first place

This commit is contained in:
John Sharratt 2017-07-01 12:25:19 +02:00
parent 701476417a
commit 55ad4b11f0
2 changed files with 29 additions and 12 deletions

View File

@ -78,14 +78,17 @@ void session::update_all(int elapsed_time)
session::~session()
{
logger::debug() << "session::~session() this=" << logger::format("%x", this);
if (_wired == true) {
for (std::list<ptr<iface> >::iterator it = _ifaces.begin();
it != _ifaces.end(); it++) {
handle_auto_unwire((*it));
}
}
for (std::list<ptr<iface> >::iterator it = _ifaces.begin();
it != _ifaces.end(); it++)
{
if (_autowire == true) {
handle_auto_unwire((*it));
}
(*it)->remove_session(_ptr);
}
}
@ -95,14 +98,15 @@ ptr<session> session::create(const ptr<proxy>& pr, const address& saddr,
{
ptr<session> se(new session());
se->_ptr = se;
se->_pr = pr;
se->_saddr = address("::") == saddr ? all_nodes : saddr;
se->_taddr = taddr;
se->_daddr = daddr;
se->_autowire = auto_wire;
se->_ttl = pr->timeout();
se->_touched = true;
se->_ptr = se;
se->_pr = pr;
se->_saddr = address("::") == saddr ? all_nodes : saddr;
se->_taddr = taddr;
se->_daddr = daddr;
se->_autowire = auto_wire;
se->_wired = false;
se->_ttl = pr->timeout();
se->_touched = true;
_sessions.push_back(se);
@ -161,6 +165,8 @@ void session::handle_auto_wire(const ptr<iface>& ifa)
<< "session::system(" << route_cmd.str() << ")";
system(route_cmd.str().c_str());
_wired = true;
}
void session::handle_auto_unwire(const ptr<iface>& ifa)
@ -181,6 +187,8 @@ void session::handle_auto_unwire(const ptr<iface>& ifa)
<< "session::system(" << route_cmd.str() << ")";
system(route_cmd.str().c_str());
_wired = false;
}
void session::handle_advert(const ptr<iface>& ifa)
@ -223,6 +231,11 @@ bool session::autowire() const
return _autowire;
}
bool session::wired() const
{
return _wired;
}
bool session::touched() const
{
return _touched;

View File

@ -34,6 +34,8 @@ private:
bool _autowire;
bool _wired;
bool _touched;
// An array of interfaces this session is monitoring for
@ -75,6 +77,8 @@ public:
bool autowire() const;
bool wired() const;
bool touched() const;
int status() const;