Giter Site home page Giter Site logo

expose sendfile/5 about ranch HOT 10 CLOSED

ninenines avatar ninenines commented on May 24, 2024
expose sendfile/5

from ranch.

Comments (10)

essen avatar essen commented on May 24, 2024

Yep.

from ranch.

dvv avatar dvv commented on May 24, 2024

Shall I prepare a PR?

from ranch.

essen avatar essen commented on May 24, 2024

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

from ranch.

dvv avatar dvv commented on May 24, 2024

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

from ranch.

essen avatar essen commented on May 24, 2024

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

from ranch.

essen avatar essen commented on May 24, 2024

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.

from ranch.

dvv avatar dvv commented on May 24, 2024

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.

from ranch.

essen avatar essen commented on May 24, 2024

Would you like to write a patch for this?

from ranch.

dvv avatar dvv commented on May 24, 2024

i hesitate since i have vague skill in ct tests.
TODO

from ranch.

essen avatar essen commented on May 24, 2024

So this has been done. Thanks everyone involved!

from ranch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.