Skip to content
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

fix(hydroflow): cleanup temp tcp networking code, fix race condition fix #1458 #1446

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

MingweiSamuel
Copy link
Member

@MingweiSamuel MingweiSamuel commented Sep 5, 2024

consolidate into one task to prevent races

@MingweiSamuel MingweiSamuel marked this pull request as draft September 5, 2024 22:09
@MingweiSamuel MingweiSamuel changed the title fix(hydroflow): fix race condition in temp tcp networking code fix(hydroflow): cleanup temp tcp networking code, fix race condition fix #1458 Sep 20, 2024
@MingweiSamuel MingweiSamuel marked this pull request as ready for review September 20, 2024 21:34
@MingweiSamuel MingweiSamuel force-pushed the tcp-temp-fix branch 2 times, most recently from bced4ad to 99846df Compare September 23, 2024 17:33
@@ -74,6 +73,7 @@ pub type TcpFramedSink<T> = Sender<(T, SocketAddr)>;
pub type TcpFramedStream<Codec: Decoder> =
Receiver<Result<(<Codec as Decoder>::Item, SocketAddr), <Codec as Decoder>::Error>>;

// TODO(mingwei): this temporary code should be replaced with a properly thought out networking system.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed.

continue;
// Calling methods in a loop, futures must be cancel-safe.
select! {
biased;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be helpful to document why biased is necessary.

// Send outgoing messages.
msg_send = recv_egress.next() => {
let Some((payload, peer_addr)) = msg_send else {
continue;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In what condition is this continue called?

}
}
});
let (send_egress, mut recv_egress) = unsync_channel::<(T, SocketAddr)>(None);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious, what was wrong with tx and rx?

loop {
// Calling methods in a loop, futures must be cancel-safe.
select! {
biased;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto on why biased is necessary.

@rohitkulshreshtha
Copy link
Contributor

Nice. Mostly LGTM, just a few questions for clarity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants