-
Notifications
You must be signed in to change notification settings - Fork 19
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
CA-289145: close socket if error occurs when using lwt connect #40
Conversation
lwt/protocol_lwt.ml
Outdated
@@ -47,7 +47,9 @@ module M = struct | |||
| Unix.Unix_error((Unix.ECONNREFUSED | Unix.ECONNABORTED | Unix.ENOENT), _, _) -> | |||
Lwt_unix.sleep 5. >>= fun () -> | |||
loop () | |||
| e -> fail e | |||
| e -> | |||
Lwt_unix.close fd; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the fd
has been closed at line 43 this will fail with Unix.EBADF
and shadow the real exception below. You should probably put it in a Lwt.catch
ignoring any error in this line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also don't use the semicolon but bind it to the Lwt.fail
below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
lwt/protocol_lwt.ml
Outdated
| e -> fail e | ||
) in | ||
| e -> | ||
Lwt_unix.close fd >>= fail e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
>>=
should be >>= fun () ->
lwt/protocol_lwt.ml
Outdated
Lwt_unix.close fd >>= fail e | ||
) | ||
>>= fun () -> | ||
let ic = Lwt_io.of_fd ~close:(fun () -> Lwt_unix.close fd) ~mode:Lwt_io.input fd in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth mentioning that (fun () -> Lwt_unix.close fd)
is the default value for ?close
, but I'd keep it there for clarity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The purpose of the code is quite clear. I think we don't need to add any more comment for it.
If David omitted the ~close
parameter when constructing ic
, then I think he should add note here that says "the default value of ?close is to close the fd"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine anyways
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As with some other PRs, please fix the typo and once the Travis build passes feel free to merge
Travis is failing with
There is a type mismatch between the return types. I think the easiest solution is to put back the |
Signed-off-by: Yang Qian <yang.qian@citrix.com>
Updated, we just need to check the exception when connecting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t understand how we decreased coverage
I think that's because adding 12 lines while deleting 10 lines.... |
Signed-off-by: Pau Ruiz Safont <pau.safont@citrix.com>
Signed-off-by: Yang Qian yang.qian@citrix.com