Skip to content

Commit adcdb8e

Browse files
pzhan9meta-codesync[bot]
authored andcommitted
Close channel first before return undeliverable and remove log (#1879)
Summary: Pull Request resolved: #1879 Two changes: * Close NetTx's `mspc::Receiver` before returning the message. Otherwise, we might get stuck on this loop if there is another thread actively writing to this NetTx: https://www.internalfb.com/code/fbsource/[5ee448cb323e2539ea2cf169644b7d829d715040]/fbcode/monarch/hyperactor/src/channel/net/client.rs?lines=586-590 New messages are still returned after `mspc::Receiver` is closed: https://www.internalfb.com/code/fbsource/[5ee448cb323e2539ea2cf169644b7d829d715040]/fbcode/monarch/hyperactor/src/channel/net.rs?lines=156-161 * Remove the log when the return_channel is closed. This log does not seem to be helpful, and also we do not log it in other places for closed `return_channel`. Reviewed By: mariusae Differential Revision: D87002126 fbshipit-source-id: 69a7b57bc9addf1bdc62cfe324a45877421f6fb4
1 parent b8d1524 commit adcdb8e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

hyperactor/src/channel/net/client.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,8 @@ async fn run<M: RemoteMessage>(
576576
// TODO(T233029051): Return reason through return_channel too.
577577
reason: _,
578578
} => {
579+
// Close the channel to prevent any further messages from being sent.
580+
receiver.close();
579581
// Return in order from oldest to newest, messages
580582
// either not acknowledged or not sent.
581583
unacked
@@ -584,9 +586,7 @@ async fn run<M: RemoteMessage>(
584586
.chain(outbox.deque.drain(..))
585587
.for_each(|queued| queued.try_return());
586588
while let Ok((msg, return_channel, _)) = receiver.try_recv() {
587-
if let Err(m) = return_channel.send(SendError(ChannelError::Closed, msg)) {
588-
tracing::warn!("failed to deliver SendError: {}", m);
589-
}
589+
let _ = return_channel.send(SendError(ChannelError::Closed, msg));
590590
}
591591
}
592592
_ => (),

0 commit comments

Comments
 (0)