summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Dounin <mdounin@mdounin.ru>2012-02-05 20:05:11 +0000
committerMaxim Dounin <mdounin@mdounin.ru>2012-02-05 20:05:11 +0000
commitf4d00a96acd56fb0d41233f5f1346f051528129a (patch)
tree1eac3a0a2be9eb417abba875275894bf05e0903e
parenta22bc749c7b170ec8883ef614dd8dd88fca53aaa (diff)
downloadnginx-f4d00a96acd56fb0d41233f5f1346f051528129a.tar.gz
Merge of r4416:
Fixed AIO error handling on FreeBSD. The aio_return() must be called regardless of the error returned by aio_error(). Not calling it resulted in various problems up to segmentation faults (as AIO events are level-triggered and were reported again and again). Additionally, in "aio sendfile" case r->blocked was incremented in case of error returned from ngx_file_aio_read(), thus causing request hangs.
-rw-r--r--src/http/ngx_http_copy_filter_module.c2
-rw-r--r--src/os/unix/ngx_file_aio_read.c27
2 files changed, 10 insertions, 19 deletions
diff --git a/src/http/ngx_http_copy_filter_module.c b/src/http/ngx_http_copy_filter_module.c
index 2d197c6e6..d52fbebe8 100644
--- a/src/http/ngx_http_copy_filter_module.c
+++ b/src/http/ngx_http_copy_filter_module.c
@@ -190,7 +190,7 @@ ngx_http_copy_filter(ngx_http_request_t *r, ngx_chain_t *in)
rc = n;
- if (file->aio) {
+ if (rc == NGX_AGAIN) {
file->aio->data = r;
file->aio->handler = ngx_http_copy_aio_sendfile_event_handler;
diff --git a/src/os/unix/ngx_file_aio_read.c b/src/os/unix/ngx_file_aio_read.c
index 5973b5b71..0bb383de5 100644
--- a/src/os/unix/ngx_file_aio_read.c
+++ b/src/os/unix/ngx_file_aio_read.c
@@ -157,24 +157,15 @@ ngx_file_aio_result(ngx_file_t *file, ngx_event_aio_t *aio, ngx_event_t *ev)
return NGX_ERROR;
}
- if (n != 0) {
- if (n == NGX_EINPROGRESS) {
- if (ev->ready) {
- ev->ready = 0;
- ngx_log_error(NGX_LOG_ALERT, file->log, n,
- "aio_read(\"%V\") still in progress",
- &file->name);
- }
-
- return NGX_AGAIN;
+ if (n == NGX_EINPROGRESS) {
+ if (ev->ready) {
+ ev->ready = 0;
+ ngx_log_error(NGX_LOG_ALERT, file->log, n,
+ "aio_read(\"%V\") still in progress",
+ &file->name);
}
- aio->err = n;
- ev->ready = 0;
-
- ngx_log_error(NGX_LOG_CRIT, file->log, n,
- "aio_read(\"%V\") failed", &file->name);
- return NGX_ERROR;
+ return NGX_AGAIN;
}
n = aio_return(&aio->aiocb);
@@ -182,9 +173,9 @@ ngx_file_aio_result(ngx_file_t *file, ngx_event_aio_t *aio, ngx_event_t *ev)
if (n == -1) {
err = ngx_errno;
aio->err = err;
- ev->ready = 0;
+ ev->ready = 1;
- ngx_log_error(NGX_LOG_ALERT, file->log, err,
+ ngx_log_error(NGX_LOG_CRIT, file->log, err,
"aio_return(\"%V\") failed", &file->name);
return NGX_ERROR;
}