Skip to content

Commit

Permalink
Fix bugs in client mode
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierHecart committed Mar 9, 2021
1 parent 059c5bf commit 9e4b622
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions zenoh/src/net/routing/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ impl Router {
let whatami = session.get_whatami()?;

let link_id = match (self.whatami, whatami) {
(whatami::CLIENT, _) => 0,
(whatami::ROUTER, whatami::ROUTER) => {
tables
.routers_net
Expand All @@ -300,14 +299,17 @@ impl Router {
.add_link(session.clone())
.await
}
_ => {
(whatami::ROUTER, whatami::PEER)
| (whatami::PEER, whatami::ROUTER)
| (whatami::PEER, whatami::PEER) => {
tables
.peers_net
.as_mut()
.unwrap()
.add_link(session.clone())
.await
}
_ => 0,
};

let handler = Arc::new(LinkStateInterceptor::new(
Expand All @@ -329,13 +331,15 @@ impl Router {
));

match (self.whatami, whatami) {
(whatami::CLIENT, _) => (),
(whatami::ROUTER, whatami::ROUTER) => {
tables.schedule_compute_trees(self.tables.clone(), whatami::ROUTER);
}
_ => {
(whatami::ROUTER, whatami::PEER)
| (whatami::PEER, whatami::ROUTER)
| (whatami::PEER, whatami::PEER) => {
tables.schedule_compute_trees(self.tables.clone(), whatami::PEER);
}
_ => (),
}
Ok(handler)
}
Expand Down Expand Up @@ -363,7 +367,6 @@ impl LinkStateInterceptor {
let mut tables = self.tables.write().await;
let whatami = self.session.get_whatami()?;
match (tables.whatami, whatami) {
(whatami::CLIENT, _) => (),
(whatami::ROUTER, whatami::ROUTER) => {
for (_, removed_node) in tables
.routers_net
Expand All @@ -379,7 +382,9 @@ impl LinkStateInterceptor {
}
tables.schedule_compute_trees(self.tables.clone(), whatami::ROUTER);
}
_ => {
(whatami::ROUTER, whatami::PEER)
| (whatami::PEER, whatami::ROUTER)
| (whatami::PEER, whatami::PEER) => {
for (_, removed_node) in tables
.peers_net
.as_mut()
Expand All @@ -393,6 +398,7 @@ impl LinkStateInterceptor {
}
tables.schedule_compute_trees(self.tables.clone(), whatami::PEER);
}
_ => (),
};

Ok(())
Expand Down

0 comments on commit 9e4b622

Please sign in to comment.