Mercurial > hg > nginx-vendor-current
comparison src/os/unix/ngx_linux_aio_read.c @ 640:eb208e0cf44d NGINX_1_1_4
nginx 1.1.4
*) Feature: the ngx_http_upstream_keepalive module.
*) Feature: the "proxy_http_version" directive.
*) Feature: the "fastcgi_keep_conn" directive.
*) Feature: the "worker_aio_requests" directive.
*) Bugfix: if nginx was built --with-file-aio it could not be run on
Linux kernel which did not support AIO.
*) Bugfix: in Linux AIO error processing.
Thanks to Hagai Avrahami.
*) Bugfix: reduced memory consumption for long-lived requests.
*) Bugfix: the module ngx_http_mp4_module did not support 64-bit MP4
"co64" atom.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Tue, 20 Sep 2011 00:00:00 +0400 |
parents | f5a8cf31a203 |
children | d0f7a625f27c |
comparison
equal
deleted
inserted
replaced
639:b516b4e38bc9 | 640:eb208e0cf44d |
---|---|
14 | 14 |
15 | 15 |
16 static void ngx_file_aio_event_handler(ngx_event_t *ev); | 16 static void ngx_file_aio_event_handler(ngx_event_t *ev); |
17 | 17 |
18 | 18 |
19 static long | 19 static int |
20 io_submit(aio_context_t ctx, long n, struct iocb **paiocb) | 20 io_submit(aio_context_t ctx, long n, struct iocb **paiocb) |
21 { | 21 { |
22 return syscall(SYS_io_submit, ctx, n, paiocb); | 22 return syscall(SYS_io_submit, ctx, n, paiocb); |
23 } | 23 } |
24 | 24 |
25 | 25 |
26 ssize_t | 26 ssize_t |
27 ngx_file_aio_read(ngx_file_t *file, u_char *buf, size_t size, off_t offset, | 27 ngx_file_aio_read(ngx_file_t *file, u_char *buf, size_t size, off_t offset, |
28 ngx_pool_t *pool) | 28 ngx_pool_t *pool) |
29 { | 29 { |
30 long n; | 30 ngx_err_t err; |
31 struct iocb *piocb[1]; | 31 struct iocb *piocb[1]; |
32 ngx_event_t *ev; | 32 ngx_event_t *ev; |
33 ngx_event_aio_t *aio; | 33 ngx_event_aio_t *aio; |
34 | 34 |
35 if (!ngx_file_aio) { | 35 if (!ngx_file_aio) { |
94 | 94 |
95 ev->handler = ngx_file_aio_event_handler; | 95 ev->handler = ngx_file_aio_event_handler; |
96 | 96 |
97 piocb[0] = &aio->aiocb; | 97 piocb[0] = &aio->aiocb; |
98 | 98 |
99 n = io_submit(ngx_aio_ctx, 1, piocb); | 99 if (io_submit(ngx_aio_ctx, 1, piocb) == 1) { |
100 | |
101 if (n == 1) { | |
102 ev->active = 1; | 100 ev->active = 1; |
103 ev->ready = 0; | 101 ev->ready = 0; |
104 ev->complete = 0; | 102 ev->complete = 0; |
105 | 103 |
106 return NGX_AGAIN; | 104 return NGX_AGAIN; |
107 } | 105 } |
108 | 106 |
109 n = -n; | 107 err = ngx_errno; |
110 | 108 |
111 if (n == NGX_EAGAIN) { | 109 if (err == NGX_EAGAIN) { |
112 return ngx_read_file(file, buf, size, offset); | 110 return ngx_read_file(file, buf, size, offset); |
113 } | 111 } |
114 | 112 |
115 ngx_log_error(NGX_LOG_CRIT, file->log, n, | 113 ngx_log_error(NGX_LOG_CRIT, file->log, err, |
116 "io_submit(\"%V\") failed", &file->name); | 114 "io_submit(\"%V\") failed", &file->name); |
117 | 115 |
118 if (n == NGX_ENOSYS) { | 116 if (err == NGX_ENOSYS) { |
119 ngx_file_aio = 0; | 117 ngx_file_aio = 0; |
120 return ngx_read_file(file, buf, size, offset); | 118 return ngx_read_file(file, buf, size, offset); |
121 } | 119 } |
122 | 120 |
123 return NGX_ERROR; | 121 return NGX_ERROR; |