The io_getevents
notification mechanism looks quite capable at first glance, so I would like something I could use with it. I just couldn't find anything yet. On Windows, it's easy: There is only TransmitFile
, which can work asynchronously (overlapped) and with some notification mechanism (IOCP, event) if you want that. There must be some equivalent on Linux, right? Or, to put my question in some context, how would I create an efficient file server on Linux?
Alas, there is nothing easy for you on Linux and nearly anything can block in the wrong circumstances (even io_submit
). In answer to your questions (in the title and within the main text):
sendfile
in Linux (Linux isn't Windows or FreeBSD). There's an excellent write-up covering sendfile
blocking, caveats and ideas in a TANK distributed log issue. That notes lighttpd came up with an "asynchronous" sendfile
hack but it's complicated and uses threads.Them's the breaks...
There's a suggestion that some future Linux kernel (later than 5.5 as were' already up to 5.5-rc7 at the time of writing) could essentially perform an asynchronous sendfile via io_uring if io_uring gains support for splice()
...