-
Notifications
You must be signed in to change notification settings - Fork 184
establish_server_generic: handle ECONNABORTED #830
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
Conversation
|
I am able to reproduce this bug somewhat consistently (happens more than half the time) with |
|
I saw the exception was raised from |
|
I was not aware that # git diff -w
diff --git a/src/unix/lwt_unix.cppo.ml b/src/unix/lwt_unix.cppo.ml
index cf0643ec5..0a519ea3c 100644
--- a/src/unix/lwt_unix.cppo.ml
+++ b/src/unix/lwt_unix.cppo.ml
@@ -1686,12 +1686,15 @@ external accept4 :
Unix.file_descr * Unix.sockaddr = "lwt_unix_accept4"
let accept_and_set_nonblock ch_fd =
+ try
if Lwt_config._HAVE_ACCEPT4 then
let (fd, addr) = accept4 ~close_on_exec:false ~nonblock:true ch_fd in
(mk_ch ~blocking:false ~set_flags:false fd, addr)
else
let (fd, addr) = Unix.accept ch_fd in
(mk_ch ~blocking:false fd, addr)
+ with
+ | Unix.Unix_error (Unix.ECONNABORTED, _, _) -> raise Retry
let accept ch =
wrap_syscall Read ch (fun _ -> accept_and_set_nonblock ch.fd)At least I have only be bothered by ECONNABORTED and never needed to do something else than calling EDIT: the above diff changes the (error) semantics of accept and deserves the documentation string to be updated. I'm curious whether there are any users of |
|
I haven't written as many servers as either of you, so I won't be much help about how this unix error is generally handled. Note that
|
Lwt does this only because it is necessary for how Lwt does non-blocking I/O (which is, at first, just try to do the I/O immediately, and let the system tell Lwt if I/O failed and Lwt needs to queue it for later). AFAIK
So that would be the wrong place to handle it, if anywhere. Separately,
and
Why should it be handled by Lwt_unix? Lwt_unix is supposed to make system calls appear to be non-blocking, and do nothing else. I don't think it should swallow any errors unless that is necessary for non-blocking operation, like |
|
For comparison, you can call |
|
@aantron I understand your argument, and agree that only |
|
I appreciate the goal to have AFAICT it's not possible to handle ECONNABORTED as a user of establish_server_* other than calling it again. I think it would make sense for it to be handled in establish_server_* |
ffb55da to
b9879de
Compare
|
Hey @reynir , sorry for the stall. I rebased on master (I had to force push, don't hesitate to force push some local change you'd have had). I also added an entry in CHANGES. AFAICT, the PR is now ready. I'll give it one more read to make sure and to leave some time for others to make comments too. |
|
ping - could this be merged and released? thanks! :) |
|
I think this can be included in the upcoming bugfix release |
Call accept again if ECONNABORTED. Fixes ocsigen#829
1416ba8 to
e03ecfa
Compare
Call accept again if ECONNABORTED.
Fixes #829