Skip to content
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

close sockets eagerly in Lwt_io.establish_server #225

Closed
c-cube opened this issue Mar 25, 2016 · 2 comments · Fixed by #258
Closed

close sockets eagerly in Lwt_io.establish_server #225

c-cube opened this issue Mar 25, 2016 · 2 comments · Fixed by #258

Comments

@c-cube
Copy link
Collaborator

c-cube commented Mar 25, 2016

Currently, at

~close:(fun () -> Lazy.force close) fd);
, it seems that establish_server doesn't close the FDs itself. A server receiving lots of short-lived connections quickly blocks by FD starvation, unless on closes the two channels manually. I think the channels should be closed by establish_server itself by default (or at least providing an optional flag to enable it), à la with_file, etc..

@c-cube
Copy link
Collaborator Author

c-cube commented Mar 27, 2016

Actually it seems that each call to the callback blocks the entire establish_server thread, so the callback should return quickly, or use Lwt.async to do the real work, which is a recipe for FD leak. Then maybe what would be nice is establish_server_async with, roughly, the same signature as establish_server, except the callback returns a unit Lwt.t and is wrapped into the safe file-closing behavior.

@aantron
Copy link
Collaborator

aantron commented Apr 28, 2016

Appears to be a duplicate of #208.

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 a pull request may close this issue.

2 participants