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

Add epollerr support #3820

Merged
merged 1 commit into from
Aug 18, 2024
Merged

Add epollerr support #3820

merged 1 commit into from
Aug 18, 2024

Conversation

tiif
Copy link
Contributor

@tiif tiif commented Aug 17, 2024

Fixes #3816

For socketpair, if the peer fd is closed while having data in its read buffer, EPOLLER will be thrown.

This is still WIP because I am currently finding a way to check if peer fd still has something in its readbuf when it is closed and add the EPOLLER flag In get_epoll_ready_events.

@RalfJung
Copy link
Member

RalfJung commented Aug 17, 2024

For socketpair, if the peer fd is closed while having data in its read buffer, EPOLLER will be thrown.

Ah, very interesting. If the peer FD is closed without any data in its read buffer, all is fine, but if there is data being discarded, that's not fine? I guess I can see how it makes sense, but it'd be better if we'd find documentation explaining this...

First sketch of an implementation:

  • add a new field to SocketPair: peer_lost_data: Cell<bool>, initially false
  • in close, if our own read buffer is non-empty and we still have a peer, set the peer's peer_lost_data flag to true
  • in get_epoll_ready_events, if peer_lost_data is true, set EPOLLERR

Does EPOLERR ever get unset again after this?

@tiif
Copy link
Contributor Author

tiif commented Aug 17, 2024

If the peer FD is closed without any data in its read buffer, all is fine, but if there is data being discarded, that's not fine?

Yes. If the peer FD read all its data before it get closed, EPOLLER won't be triggered.

Does EPOLERR ever get unset again after this?

In the context of the current test case we have in this PR, I think EPOLLER can only be triggered once because we only can close the peer_fd for once.

@rustbot author

@rustbot rustbot added the S-waiting-on-author Status: Waiting for the PR author to address review comments label Aug 17, 2024
@tiif tiif marked this pull request as ready for review August 18, 2024 08:27
@tiif
Copy link
Contributor Author

tiif commented Aug 18, 2024

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Waiting for a review to complete and removed S-waiting-on-author Status: Waiting for the PR author to address review comments labels Aug 18, 2024
@RalfJung RalfJung changed the title Add epoller support Add epollere support Aug 18, 2024
@RalfJung RalfJung changed the title Add epollere support Add epollerr support Aug 18, 2024
@RalfJung
Copy link
Member

Looks good, thanks :)
@bors r+

@bors
Copy link
Contributor

bors commented Aug 18, 2024

📌 Commit 81c02da has been approved by RalfJung

It is now in the queue for this repository.

@RalfJung RalfJung removed the S-waiting-on-review Status: Waiting for a review to complete label Aug 18, 2024
@bors
Copy link
Contributor

bors commented Aug 18, 2024

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

@bors
Copy link
Contributor

bors commented Aug 18, 2024

🔒 Merge conflict

This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again.

How do I rebase?

Assuming self is your fork and upstream is this repository, you can resolve the conflict following these steps:

  1. git checkout epoller (switch to your branch)
  2. git fetch upstream master (retrieve the latest master)
  3. git rebase upstream/master -p (rebase on top of it)
  4. Follow the on-screen instruction to resolve conflicts (check git status if you got lost).
  5. git push self epoller --force-with-lease (update this PR)

You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial.

Please avoid the "Resolve conflicts" button on GitHub. It uses git merge instead of git rebase which makes the PR commit history more difficult to read.

Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Cargo.lock conflict is handled during merge and rebase. This is normal, and you should still perform step 5 to update this PR.

Error message
Auto-merging tests/pass-dep/libc/libc-epoll.rs
CONFLICT (content): Merge conflict in tests/pass-dep/libc/libc-epoll.rs
Auto-merging src/shims/unix/linux/epoll.rs
Automatic merge failed; fix conflicts and then commit the result.

@RalfJung
Copy link
Member

@rustbot author

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

tiif commented Aug 18, 2024

Maybe it will conflict again after #3818 landed, I will come back later to check.

EDIT: oh that haven't landed

@RalfJung
Copy link
Member

We'll see. :)
@bors r+

@bors
Copy link
Contributor

bors commented Aug 18, 2024

📌 Commit 7ca2aa5 has been approved by RalfJung

It is now in the queue for this repository.

@RalfJung
Copy link
Member

Ah yes they both add tests to the end of the same file so they will definitely conflict there.

@bors
Copy link
Contributor

bors commented Aug 18, 2024

🔒 Merge conflict

This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again.

How do I rebase?

Assuming self is your fork and upstream is this repository, you can resolve the conflict following these steps:

  1. git checkout epoller (switch to your branch)
  2. git fetch upstream master (retrieve the latest master)
  3. git rebase upstream/master -p (rebase on top of it)
  4. Follow the on-screen instruction to resolve conflicts (check git status if you got lost).
  5. git push self epoller --force-with-lease (update this PR)

You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial.

Please avoid the "Resolve conflicts" button on GitHub. It uses git merge instead of git rebase which makes the PR commit history more difficult to read.

Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Cargo.lock conflict is handled during merge and rebase. This is normal, and you should still perform step 5 to update this PR.

Error message
Auto-merging tests/pass-dep/libc/libc-epoll.rs
CONFLICT (content): Merge conflict in tests/pass-dep/libc/libc-epoll.rs
Auto-merging src/shims/unix/linux/epoll.rs
Automatic merge failed; fix conflicts and then commit the result.

@tiif
Copy link
Contributor Author

tiif commented Aug 18, 2024

@RalfJung Alright, last one. Thanks for being fast in reviewing this stream of PRs. :)

@RalfJung
Copy link
Member

Thanks for being fast in reacting to feedback and conflicts. :)
@bors r+

@bors
Copy link
Contributor

bors commented Aug 18, 2024

📌 Commit 6e76ba3 has been approved by RalfJung

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Aug 18, 2024

⌛ Testing commit 6e76ba3 with merge 0665f6e...

@bors
Copy link
Contributor

bors commented Aug 18, 2024

☀️ Test successful - checks-actions
Approved by: RalfJung
Pushing 0665f6e to master...

1 similar comment
@bors
Copy link
Contributor

bors commented Aug 18, 2024

☀️ Test successful - checks-actions
Approved by: RalfJung
Pushing 0665f6e to master...

@bors bors merged commit 0665f6e into rust-lang:master Aug 18, 2024
8 checks passed
@tiif tiif deleted the epoller branch August 18, 2024 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

epoll does not report EPOLLERR events
4 participants