Skip to content

Fix descriptor leak on thread cancellation for the Lwt client#446

Closed
hcarty wants to merge 1 commit intomirage:masterfrom
hcarty:lwt-client-close-fds
Closed

Fix descriptor leak on thread cancellation for the Lwt client#446
hcarty wants to merge 1 commit intomirage:masterfrom
hcarty:lwt-client-close-fds

Conversation

@hcarty
Copy link
Copy Markdown
Contributor

@hcarty hcarty commented Dec 1, 2015

I've been testing this patch on an internal project and haven't seen any leaks since it was applied.

Possibly related to #414.

@rgrinberg
Copy link
Copy Markdown
Member

I'm convinced that such a change should go in.

However, what about adding this logic inside read_response itself?

Also, perhaps it makes sense to use Lwt.{on_termination,on_failure} rather than just Lwt.on_cancel?

@hcarty
Copy link
Copy Markdown
Contributor Author

hcarty commented Dec 3, 2015

The change could use Lwt.on_termination. It is already used here so that makes sense as an alternative.

Is it safe to call closefn multiple times? If so then it could reduce some code duplication to add Lwt.on_failure inside read_response.

@rgrinberg
Copy link
Copy Markdown
Member

I believe that Lwt.on_termination [1] only executes after the stream has been exhausted. You can cancel/raise without exhausting the stream which would prevent the termination callback from executing. I should verify this though.

I think closefn is idempotent, and if it's not we should consider making it like that.

[1] https://github.com/rgrinberg/lwt/blob/master/src/core/lwt_stream.mli#L227-L230

@hcarty
Copy link
Copy Markdown
Contributor Author

hcarty commented Dec 8, 2015

I've updated the change to wrap read_response instead.

@rgrinberg
Copy link
Copy Markdown
Member

Merged in #447

Thanks

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.

2 participants