comparison src/http/ngx_http_copy_filter_module.c @ 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 586969d972b9
children ccad84a174e0
comparison
equal deleted inserted replaced
5497:2cfc095a607a 5498:d39a69427056
167 167
168 file = c->busy_sendfile->file; 168 file = c->busy_sendfile->file;
169 offset = c->busy_sendfile->file_pos; 169 offset = c->busy_sendfile->file_pos;
170 170
171 if (file->aio) { 171 if (file->aio) {
172 c->aio_sendfile = (offset != file->aio->last_offset); 172 c->busy_count = (offset == file->aio->last_offset) ?
173 c->busy_count + 1 : 0;
173 file->aio->last_offset = offset; 174 file->aio->last_offset = offset;
174 175
175 if (c->aio_sendfile == 0) { 176 if (c->busy_count > 2) {
176 ngx_log_error(NGX_LOG_ALERT, c->log, 0, 177 ngx_log_error(NGX_LOG_ALERT, c->log, 0,
177 "sendfile(%V) returned busy again", 178 "sendfile(%V) returned busy again",
178 &file->name); 179 &file->name);
180 c->aio_sendfile = 0;
179 } 181 }
180 } 182 }
181 183
182 c->busy_sendfile = NULL; 184 c->busy_sendfile = NULL;
183 e = (ngx_http_ephemeral_t *) &r->uri_start; 185 e = (ngx_http_ephemeral_t *) &r->uri_start;