Skip to content

Commit

Permalink
cohttp-lwt: Don't leak asynchronous exceptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
mefyl committed Jul 29, 2023
1 parent b0104b4 commit d8449c7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cohttp-lwt/src/connection.ml
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,13 @@ module Make (Net : S.Net) : S.Connection with module Net = Net = struct
persistent;
}
in
let on_failure e = connection.state <- Failed e in
Lwt.on_any channels
(fun channels ->
connection.state <- Full channels;
Lwt.async (fun () -> reader connection);
Lwt.async (fun () -> writer connection))
(fun e -> connection.state <- Failed e);
Lwt.dont_wait (fun () -> reader connection) on_failure;
Lwt.dont_wait (fun () -> writer connection) on_failure)
on_failure;
connection
let connect ?finalise ?persistent ?ctx uri =
Expand Down

0 comments on commit d8449c7

Please sign in to comment.