[PATCH] HTTP/2: fixed sendfile() aio handling
Maxim Dounin
mdounin at mdounin.ru
Thu Nov 25 19:06:04 UTC 2021
Hello!
On Thu, Nov 25, 2021 at 08:42:59PM +0300, Sergey Kandaurov wrote:
[...]
> > Full patch:
> >
> > # HG changeset patch
> > # User Maxim Dounin <mdounin at mdounin.ru>
> > # Date 1637847703 -10800
> > # Thu Nov 25 16:41:43 2021 +0300
> > # Node ID c960e182900a8d0b7f3041731ba416f2c7e69d14
> > # Parent 3443c02ca1d183fe52bf8af66627c94be2b2f785
> > HTTP/2: fixed "task already active" with sendfile in threads.
> >
> > With sendfile in threads, "task already active" alerts might appear in logs
> > if a write event happens on the main HTTP/2 connection, triggering a sendfile
> > in threads while another thread operation is already running. Observed
> > with "aio threads; aio_write on; sendfile on;" and with thread event handlers
> > modified to post a write event to the main HTTP/2 connection (though can
> > happen without any modifications).
> >
> > Similarly, sendfile() with AIO preloading on FreeBSD can trigger duplicate
> > aio operation, resulting in "second aio post" alerts. This is, however,
> > harder to reproduce, especially on modern FreeBSD systems, since sendfile()
> > usually does not return EBUSY.
> >
> > Fix is to avoid starting a sendfile operation if other thread operation
> > is active by checking r->aio in the thread handler (and, similarly, in
> > aio preload handler). The added check also makes duplicate calls protection
> > redundant, so it is removed.
> >
> > [..]
>
> Overall, it looks good.
Committed, thanks.
--
Maxim Dounin
http://mdounin.ru/
More information about the nginx-devel
mailing list