Mercurial > hg > nginx
comparison src/event/ngx_event.h @ 7985:ec2e6893caaa
Simplified sendfile(SF_NODISKIO) usage.
Starting with FreeBSD 11, there is no need to use AIO operations to preload
data into cache for sendfile(SF_NODISKIO) to work. Instead, sendfile()
handles non-blocking loading data from disk by itself. It still can, however,
return EBUSY if a page is already being loaded (for example, by a different
process). If this happens, we now post an event for the next event loop
iteration, so sendfile() is retried "after a short period", as manpage
recommends.
The limit of the number of EBUSY tolerated without any progress is preserved,
but now it does not result in an alert, since on an idle system event loop
iteration might be very short and EBUSY can happen many times in a row.
Instead, SF_NODISKIO is simply disabled for one call once the limit is
reached.
With this change, sendfile(SF_NODISKIO) is now used automatically as long as
sendfile() is enabled, and no longer requires "aio on;".
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 27 Dec 2021 19:48:33 +0300 |
parents | efd71d49bde0 |
children | e2d07e4ec636 eaf356a35f5d |
comparison
equal
deleted
inserted
replaced
7984:ae992b5a27b2 | 7985:ec2e6893caaa |
---|---|
145 ngx_event_handler_pt handler; | 145 ngx_event_handler_pt handler; |
146 ngx_file_t *file; | 146 ngx_file_t *file; |
147 | 147 |
148 ngx_fd_t fd; | 148 ngx_fd_t fd; |
149 | 149 |
150 #if (NGX_HAVE_AIO_SENDFILE || NGX_COMPAT) | |
151 ssize_t (*preload_handler)(ngx_buf_t *file); | |
152 #endif | |
153 | |
154 #if (NGX_HAVE_EVENTFD) | 150 #if (NGX_HAVE_EVENTFD) |
155 int64_t res; | 151 int64_t res; |
156 #endif | 152 #endif |
157 | 153 |
158 #if !(NGX_HAVE_EVENTFD) || (NGX_TEST_BUILD_EPOLL) | 154 #if !(NGX_HAVE_EVENTFD) || (NGX_TEST_BUILD_EPOLL) |