]> git.kaiwu.me - nginx.git/commit
HTTP/2: fixed "task already active" with sendfile in threads.
authorMaxim Dounin <mdounin@mdounin.ru>
Thu, 25 Nov 2021 19:02:05 +0000 (22:02 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Thu, 25 Nov 2021 19:02:05 +0000 (22:02 +0300)
commit2361e98a34ca3b66c45fbb4e906401b430e41013
treeb7981c366e436e5a110d414e150f22f5750cfeac
parent5c3249964403356601e64ab701f2e563a1f98630
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.
src/http/ngx_http_copy_filter_module.c
src/http/ngx_http_upstream.c
src/os/unix/ngx_freebsd_sendfile_chain.c
src/os/unix/ngx_linux_sendfile_chain.c