Skip to content

Commit

Permalink
Send simple sub and qabl declarations after releasing tables lock (mi…
Browse files Browse the repository at this point in the history
…ssing places)
  • Loading branch information
OlivierHecart committed Jun 11, 2024
1 parent d070e7c commit 5191af2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
18 changes: 15 additions & 3 deletions zenoh/src/net/primitives/demux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,21 @@ impl TransportPeerEventHandler for DeMux {
NetworkBody::ResponseFinal(m) => self.face.send_response_final(m),
NetworkBody::OAM(m) => {
if let Some(transport) = self.transport.as_ref() {
let mut declares = vec![];
let ctrl_lock = zlock!(self.face.tables.ctrl_lock);
let mut tables = zwrite!(self.face.tables.tables);
ctrl_lock.handle_oam(
&mut tables,
&self.face.tables,
m,
transport,
&mut |p, m| p.send_declare(m),
)?
&mut |p, m| declares.push((p.clone(), m)),
)?;
drop(tables);
drop(ctrl_lock);
for (p, m) in declares {
p.send_declare(m);
}
}
}
}
Expand All @@ -95,11 +101,17 @@ impl TransportPeerEventHandler for DeMux {
fn closing(&self) {
self.face.send_close();
if let Some(transport) = self.transport.as_ref() {
let mut declares = vec![];
let ctrl_lock = zlock!(self.face.tables.ctrl_lock);
let mut tables = zwrite!(self.face.tables.tables);
let _ = ctrl_lock.closing(&mut tables, &self.face.tables, transport, &mut |p, m| {
p.send_declare(m)
declares.push((p.clone(), m))
});
drop(tables);
drop(ctrl_lock);
for (p, m) in declares {
p.send_declare(m);
}
}
}

Expand Down
8 changes: 7 additions & 1 deletion zenoh/src/net/routing/dispatcher/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,13 @@ pub fn close_face(tables: &TablesLock, face: &Weak<FaceState>) {
tracing::debug!("Close {}", face);
face.task_controller.terminate_all(Duration::from_secs(10));
finalize_pending_queries(tables, &mut face);
zlock!(tables.ctrl_lock).close_face(tables, &mut face, &mut |p, m| p.send_declare(m));
let mut declares = vec![];
let ctrl_lock = zlock!(tables.ctrl_lock);
ctrl_lock.close_face(tables, &mut face, &mut |p, m| declares.push((p.clone(), m)));
drop(ctrl_lock);
for (p, m) in declares {
p.send_declare(m);
}
}
None => tracing::error!("Face already closed!"),
}
Expand Down

0 comments on commit 5191af2

Please sign in to comment.