mirror of
https://github.com/nginx/nginx.git
synced 2025-06-13 06:12:44 +08:00
retry aio sendfile if data are ready
This commit is contained in:
parent
06bb9d294a
commit
9f9054df82
@ -133,6 +133,7 @@ ngx_http_copy_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
r->request_output = 1;
|
r->request_output = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for ( ;; ) {
|
||||||
rc = ngx_output_chain(ctx, in);
|
rc = ngx_output_chain(ctx, in);
|
||||||
|
|
||||||
if (ctx->in == NULL) {
|
if (ctx->in == NULL) {
|
||||||
@ -148,6 +149,7 @@ ngx_http_copy_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
#if (NGX_HAVE_FILE_AIO && NGX_HAVE_AIO_SENDFILE)
|
#if (NGX_HAVE_FILE_AIO && NGX_HAVE_AIO_SENDFILE)
|
||||||
|
|
||||||
if (c->busy_sendfile) {
|
if (c->busy_sendfile) {
|
||||||
|
ssize_t n;
|
||||||
off_t offset;
|
off_t offset;
|
||||||
ngx_file_t *file;
|
ngx_file_t *file;
|
||||||
ngx_http_ephemeral_t *e;
|
ngx_http_ephemeral_t *e;
|
||||||
@ -161,14 +163,21 @@ ngx_http_copy_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
|
|
||||||
if (c->aio_sendfile == 0) {
|
if (c->aio_sendfile == 0) {
|
||||||
ngx_log_error(NGX_LOG_ALERT, c->log, 0,
|
ngx_log_error(NGX_LOG_ALERT, c->log, 0,
|
||||||
"sendfile(%V) returned busy again", &file->name);
|
"sendfile(%V) returned busy again",
|
||||||
|
&file->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c->busy_sendfile = NULL;
|
c->busy_sendfile = NULL;
|
||||||
e = (ngx_http_ephemeral_t *) &r->uri_start;
|
e = (ngx_http_ephemeral_t *) &r->uri_start;
|
||||||
|
|
||||||
(void) ngx_file_aio_read(file, e->preload, 4, offset, r->pool);
|
n = ngx_file_aio_read(file, e->preload, 4, offset, r->pool);
|
||||||
|
|
||||||
|
if (n > 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = n;
|
||||||
|
|
||||||
if (file->aio) {
|
if (file->aio) {
|
||||||
file->aio->data = r;
|
file->aio->data = r;
|
||||||
@ -178,10 +187,10 @@ ngx_http_copy_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
|||||||
r->aio = 1;
|
r->aio = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user