Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions async/cohttp_async.ml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ module Client = struct
| `Ok res ->
(* Build a response pipe for the body *)
let rd = pipe_of_body (Response.read_body_chunk res) ic oc in
don't_wait_for (
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why not wait for these to close? It should be pretty fast, and anything else seems race-prone if the close isn't the right thing to do for some reason.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Because we don't how long it will take the pipe to finish reading. For example, what if we have some huge body and the pipe will stall with push back until the client has read something.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh of course -- sorry, I missed the vital Pipe.closed >>= on my first read. In my defence, it's because I'm busy hacking on the Conduit patches to let a release be cut ;-)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

NP ^_^. Are we having a release shortly after?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yep! I never intended for trunk to accumulate patches this long. Conduit is necessary for Mirage HTTP(S) requests to work though, so lots of combinations to test (and a DNS resolver needs to be hooked in too, which is ongoing in mirage/ocaml-dns)

Pipe.closed rd >>= fun () ->
Deferred.all_ignore [Reader.close ic; Writer.close oc]
);
return (res, `Pipe rd)

let get ?interrupt ?headers uri =
Expand Down