wahern / cqueues

Continuation Queues: Embeddable asynchronous networking, threading, and notification framework for Lua on Unix.
http://25thandclement.com/~william/projects/cqueues.html
MIT License
244 stars 37 forks source link

document socket.fdopen #219

Closed vcunat closed 5 years ago

vcunat commented 5 years ago

I consider it quite an important function for e.g. systemd-based services, so I'd feel better if it were officially blessed (in docs).

I only spent a few minutes looking at the sources, trying to document the exact meaning, so it might not be accurate. Still, it worked OK for us in combination with http.server.new()

vcunat commented 5 years ago

@daurnimator: do I understand the code correctly that the only difference of dup is that it duplicates the FD and owns the copy (i.e. closes it when the cqueues socket closes, or something like that).

EDIT: BTW, assuming that's so, I can't see why prefer .dup in the systemd.socket case.

daurnimator commented 5 years ago

do I understand the code correctly that the only difference of dup is that it duplicates the FD and owns the copy (i.e. closes it when the cqueues socket closes, or something like that).

Yes: dup makes a copy while fdopen takes ownership.

BTW, assuming that's so, I can't see why prefer .dup in the systemd.socket case.

You don't. as I said above: "systemd fd storage is a correct usecase" (for .fdopen)

vcunat commented 5 years ago

I'm not sure about the exact formulations... is this OK? Feel free to amend and push directly a version you like.

vcunat commented 5 years ago

Added. I actually didn't realize that you don't seem to have write access to this repo :-)

BTW, I didn't document that you can pass a table with .fd to these functions. I can't see an advantage when there's only one parameter.