Skip to content

Commit

Permalink
fix(network/worker): forget response token to prevent recursion on drop
Browse files Browse the repository at this point in the history
  • Loading branch information
Erigara authored and loyd committed Jan 22, 2025
1 parent 5f4a994 commit 26a6d56
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions elfo-network/src/worker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -891,19 +891,26 @@ impl remote::RemoteHandle for RemoteHandle {

let recipient = NetworkAddr::from_remote(token.sender());

let mut item = Some(KanalItem {
recipient,
envelope,
token: Some(token),
});

if likely(self.tx_flows.do_acquire(recipient)) {
let item = KanalItem {
recipient,
envelope,
token: Some(token),
};
match self.tx.try_send(item) {
match self.tx.try_send_option(&mut item) {
Ok(true) => return,
Ok(false) => unreachable!(),
Err(_) => {}
}
}

if let Some(item) = item {
let token = item.token.expect("response token set above");
// Flow is closed, token is not required anymore
token.forget();
}

trace!(addr = %recipient, "flow is closed, response is lost");
}
}

0 comments on commit 26a6d56

Please sign in to comment.