expose sendfile/5 #22

dvv opened this Issue Dec 25, 2012 · 10 comments


None yet

2 participants

dvv commented Dec 25, 2012

This would be the first step towards ninenines/cowboy#306.

( Sorry for filing this while Xmas :)

essen commented Dec 25, 2012


dvv commented Dec 25, 2012

Shall I prepare a PR?

essen commented Dec 25, 2012

Feel free to, but you'll need to add a ct test for it (for ssl at the very least).

dvv commented Dec 25, 2012

I see no existing tests for sendfile/2 to use as a starter...

essen commented Dec 25, 2012

There are none because sendfile/2 is trivial while a sendfile with offset/length is harder.

essen commented Dec 26, 2012

There's a sendfile_fallback function in the file module. Can probably start looking there. Also we probably can do with just a sendfile(Socket, Filename, Start, Length) or something because this way we open the file ourselves and not the user, and the one option available otherwise is chunk_size and is probably not important on a per-file basis.

dvv commented Dec 26, 2012

You mean ranch_(tcp|ssl) might only expose sendfile/4, right? I'm pro, with addition in having also sendfile(Socket, File, Start, Length) exposed. The rationale is that it maps 1-1 to file:sendfile/5 in case of plain TCP which is the major case.
The question though who's in charge to close File, I believe it's left to user.
In either event, sendfile/4 is more solid solution imho.

What to ranch_ssl, I'd recommend to put SSL-terminators such as modern haproxy which does also load-balancing and other sweets.

essen commented Feb 14, 2013

Would you like to write a patch for this?

dvv commented Feb 14, 2013

i hesitate since i have vague skill in ct tests.

essen commented Aug 27, 2013

So this has been done. Thanks everyone involved!

@essen essen closed this Aug 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment