Mercurial > hg > nginx
changeset 5498:d39a69427056
Allowed up to two EBUSY errors from sendfile().
Fallback to synchronous sendfile() now only done on 3rd EBUSY without
any progress in a row. Not falling back is believed to be better
in case of occasional EBUSY, though protection is still needed to
make sure there will be no infinite loop.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Sat, 04 Jan 2014 03:31:58 +0400 |
parents | 2cfc095a607a |
children | b91bcba29351 |
files | src/core/ngx_connection.h src/http/ngx_http_copy_filter_module.c |
diffstat | 2 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/core/ngx_connection.h Fri Dec 27 19:40:04 2013 +0400 +++ b/src/core/ngx_connection.h Sat Jan 04 03:31:58 2014 +0400 @@ -177,6 +177,7 @@ #if (NGX_HAVE_AIO_SENDFILE) unsigned aio_sendfile:1; + unsigned busy_count:2; ngx_buf_t *busy_sendfile; #endif
--- a/src/http/ngx_http_copy_filter_module.c Fri Dec 27 19:40:04 2013 +0400 +++ b/src/http/ngx_http_copy_filter_module.c Sat Jan 04 03:31:58 2014 +0400 @@ -169,13 +169,15 @@ offset = c->busy_sendfile->file_pos; if (file->aio) { - c->aio_sendfile = (offset != file->aio->last_offset); + c->busy_count = (offset == file->aio->last_offset) ? + c->busy_count + 1 : 0; file->aio->last_offset = offset; - if (c->aio_sendfile == 0) { + if (c->busy_count > 2) { ngx_log_error(NGX_LOG_ALERT, c->log, 0, "sendfile(%V) returned busy again", &file->name); + c->aio_sendfile = 0; } }