Re: aio_read2() and aio_write2()

Vinícius dos Santos Oliveira <[email protected]> Sat, 13 Jan 2024 21:50:58 -0300
Newsgroups gmane.os.freebsd.devel.threading
Message-ID <CAK9Rve+uYpxWyRPwh6gxjRkisU7WPKjXicU9+YiqFG-=c3trvg@mail.gmail.com>
Em sáb., 13 de jan. de 2024 às 21:35, Konstantin Belousov
<[email protected]> escreveu:
> In principle the function of the new flag could be done like
>         aio.aio_offset = lseek(fd, 0, SEEK_CUR);
>         aio_read(&aio);
> with the dis-advantage of requiring two syscalls instead of one.

There are more disadvantages besides the extra syscall.

I've built a green threading framework for Lua on top of Boost.Asio.
However I also added support for sandboxed actors (capsicum and jails
on FreeBSD). For file descriptors received through SCM_RIGHTS from
sandboxed processes, I really don't want to risk blocking the thread
(DoS) going through O_NONBLOCK (file IO is always ready, and that's
why AIO exists). So, for these file descriptors (one can never know
their "type"... whether they refer to pipes and O_NONBLOCK is enough,
or they refer to files and AIO should be used), I'll use AIO as well.
On Linux I can get away by just using io_uring for everything.

Anyway, that's *another* use case. Other applications built on top of
Boost.Asio have their own reasoning for choosing between the
streaming/random_access interfaces. And they already work on Linux and
Windows.


-- 
Vinícius dos Santos Oliveira
https://vinipsmaker.github.io/