8000 Fixes client downlink runtime attachment bug by SirCipher · Pull Request #684 · swimos/swim-rust · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fixes client downlink runtime attachment bug #684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions swimos_client/src/pending.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,6 @@ impl<'f> PendingConnections<'f> {
)
}

fn map_waiters(
col: Option<FnvHashMap<Key, Vec<PendingDownlink>>>,
) -> impl Iterator<Item = (Key, PendingDownlink)> {
col.unwrap_or_default()
.into_iter()
.flat_map(|(key, downlinks)| downlinks.into_iter().map(move |dl| (key.clone(), dl)))
}

pub fn feed_task(&self, task: BoxFuture<'f, Either<PendingDns, PendingHandshake>>) {
self.tasks.push(task)
}
Expand All @@ -110,14 +102,18 @@ impl<'f> PendingConnections<'f> {
&mut self,
host: Text,
) -> impl Iterator<Item = (Key, PendingDownlink)> {
Self::map_waiters(self.waiters.remove(&WaiterKey::Connection(host)))
self.waiters
.remove(&WaiterKey::Connection(host))
.unwrap_or_default()
.into_iter()
.flat_map(|(key, downlinks)| downlinks.into_iter().map(move |dl| (key.clone(), dl)))
}

pub fn drain_runtime_queue(
&mut self,
addr: SocketAddr,
) -> impl Iterator<Item = (Key, PendingDownlink)> {
Self::map_waiters(self.waiters.remove(&WaiterKey::Runtime(addr)))
pub fn drain_runtime_queue(&mut self, addr: SocketAddr, key: &Key) -> Vec<PendingDownlink> {
match self.waiters.get_mut(&WaiterKey::Runtime(addr)) {
Some(waiters) => waiters.remove(key).unwrap_or_default(),
None => Vec::new(),
}
}

pub fn waiting_on(&self, addr: SocketAddr, key: &Key) -> bool {
Expand Down
8 changes: 4 additions & 4 deletions swimos_client/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ async fn runtime_task<Net, Ws, Provider>(
.boxed(),
);

for (_key, pending_downlink) in pending.drain_runtime_queue(sock) {
for pending_downlink in pending.drain_runtime_queue(sock, &peer_key) {
attachment_tasks
.push(attach_downlink(attach.clone(), pending_downlink).boxed());
}
Expand All @@ -526,7 +526,7 @@ async fn runtime_task<Net, Ws, Provider>(
None => {
let error =
Err(DownlinkRuntimeError::new(DownlinkErrorKind::RemoteStopped).shared());
for (_key, pending_downlink) in pending.drain_runtime_queue(sock) {
for pending_downlink in pending.drain_runtime_queue(sock, &key) {
let PendingDownlink {
callback,
address,
Expand All @@ -543,7 +543,7 @@ async fn runtime_task<Net, Ws, Provider>(
RuntimeEvent::DownlinkRuntimeStarted {
sock,
result: Err((cause, host)),
..
key,
} => {
error!(error = %cause, host = %host, "Failed to start a downlink runtime to host: ");

Expand All @@ -552,7 +552,7 @@ async fn r 5D53 untime_task<Net, Ws, Provider>(
cause,
)
.shared());
for (_key, pending_downlink) in pending.drain_runtime_queue(sock) {
for pending_downlink in pending.drain_runtime_queue(sock, &key) {
let PendingDownlink {
callback,
address,
Expand Down
Loading
0