Skip to content

Commit 8be3321

Browse files
authored
Also fix the close bug for publish namespace. (#983)
1 parent 6e8d198 commit 8be3321

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

rs/moq-lite/src/ietf/publisher.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,17 @@ impl<S: web_transport_trait::Session> Publisher<S> {
4343
// Track request_id → namespace mapping for v16 PublishNamespaceDone
4444
let mut namespace_requests: HashMap<crate::PathOwned, RequestId> = HashMap::new();
4545

46-
while let Some((path, active)) = self.origin.announced().await {
46+
loop {
47+
let announced = tokio::select! {
48+
biased;
49+
_ = self.session.closed() => return Ok(()),
50+
announced = self.origin.announced() => announced,
51+
};
52+
53+
let Some((path, active)) = announced else {
54+
break;
55+
};
56+
4757
let suffix = path.to_owned();
4858

4959
if active.is_some() {
@@ -69,6 +79,16 @@ impl<S: web_transport_trait::Session> Publisher<S> {
6979
}
7080
}
7181

82+
// Flush pending PublishNamespaceDone for any remaining active namespaces.
83+
for (suffix, request_id) in namespace_requests {
84+
self.control
85+
.send(ietf::PublishNamespaceDone {
86+
track_namespace: suffix,
87+
request_id,
88+
})
89+
.ok();
90+
}
91+
7292
Ok(())
7393
}
7494

@@ -189,7 +209,7 @@ impl<S: web_transport_trait::Session> Publisher<S> {
189209
let group = tokio::select! {
190210
biased;
191211
_ = &mut cancel => return Ok(()),
192-
_ = session.closed() => return Err(Error::Transport),
212+
_ = session.closed() => return Ok(()),
193213
Some(group) = track.next_group().transpose() => group,
194214
Some(_) = async { Some(old_group.as_mut()?.await) } => {
195215
old_group = None;

0 commit comments

Comments
 (0)