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

[WIP] blocking unnamed_socket #4072

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from
Draft

[WIP] blocking unnamed_socket #4072

wants to merge 19 commits into from

Conversation

tiif
Copy link
Contributor

@tiif tiif commented Dec 4, 2024

This is a very WIP PR opened to ask for some feedback.

TODO:

  • Report deadlock error when blocked on closed anonsocket discussion happened here (depends on the size of the PR, might split it into another PR)
  • Write tests
  • Read through all the comments in the code again

@rustbot author

@rustbot rustbot added the S-waiting-on-author Status: Waiting for the PR author to address review comments label Dec 4, 2024
@tiif
Copy link
Contributor Author

tiif commented Dec 4, 2024

Planning to open a minor clean-up PR to remove some unused variable here before getting back to this.

@rustbot label S-blocked

@rustbot rustbot added the S-blocked Status: blocked on something happening somewhere else label Dec 4, 2024
@bors
Copy link
Contributor

bors commented Dec 5, 2024

☔ The latest upstream changes (presumably #4074) made this pull request unmergeable. Please resolve the merge conflicts.

@@ -171,82 +167,143 @@ impl FileDescription for AnonSocket {
}

/// Write to AnonSocket based on the space available and return the written byte size.
/// This is only for socketpair/pipe without O_NONBLOCK flag.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just something on top of my mind while working on this, if we were to support O_NONBLOCK flag in fcntl, which has the ability of setting a file descriptor with blocking ability to non-blocking, we need to be careful of it's interaction with all the blocking operation here.

let weak_self_ref = self_ref.downgrade();

// We handle return earlier if we hit these two case, and only do the actual read and
// blocking in anonsocket_read.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand this comment. What do you mean by "handle return"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah it should be "We return early..."

But please ignore the comment for now, I plan to remove that because one of the cases should be moved to the helper function.

}
// TODO: We might need to decide what to do if peer_fd is closed when read is blocked.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It turns out that we can just follow what we did previously:

for read, just keep reading if there are data inside readbuf.

for write, return ecx.set_last_error_and_return(ErrorKind::BrokenPipe, &dest);.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-blocked Status: blocked on something happening somewhere else S-waiting-on-author Status: Waiting for the PR author to address review comments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants