8000 ignore ENOTCONN errors on socket shutdown by avsm · Pull Request #533 · ocaml-multicore/eio · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ignore ENOTCONN errors on socket shutdown #533

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

Merged
merged 1 commit into from
Jun 2, 2023

Conversation

avsm
Copy link
Contributor
@avsm avsm commented May 29, 2023

macOS can return ENOTCONN occasionally even if the other side did a graceful shutdown. This changes all the backends to ignore ENOTCONN; even though it's unlikely to show up on Linux, there's still not much point throwing the exception from a shutdown on any of the platforms.

Fixes #521

@avsm avsm marked this pull request as ready for review May 29, 2023 19:47
Fd.use_exn "shutdown" sock (fun fd -> Unix.shutdown fd cmd)
with
| Unix.Unix_error (Unix.ENOTCONN, _, _) -> ()
| Unix.Unix_error (code, name, arg) -> raise @@ Err.wrap code name arg
8000
Copy link
Collaborator

Choose a reason for hiding this comment

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

Note: The idea was that the low-level functions in eio_posix raise Unix exceptions, with the wrapping done outside (in Flow.shutdown). So I think we should remove the last line here.

(However, this is inconsistent with eio_linux, which does wrap in its low-level module, and I see we do wrap in connect. And if we're going to catch exceptions then it would be more efficient to do it in one place.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, we should move the ENOTCONN handling to the high-level API. The low-level one should match the Unix module and raise the same exception it does.

macOS can return ENOTCONN occasionally even if the other side did
a graceful shutdown.  This changes all the backends to ignore
ENOTCONN; even though it's unlikely to show up on Linux, there's
still not much point throwing the exception from a shutdown on any
of the platforms.

Fixes ocaml-multicore#521
Copy link
Collaborator
@talex5 talex5 left a comment

Choose a reason for hiding this comment

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

I force-pushed the suggested change. Ready to merge once CI is happy.

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.

3DC6 Should ignore ENOTCONN from shutdown?
2 participants
0