comparison src/os/unix/ngx_linux_aio_read.c @ 634:0d6525917227 NGINX_1_0_7

nginx 1.0.7 *) Change: now if total size of all ranges is greater than source response size, then nginx disables ranges and returns just the source response. *) Feature: the "max_ranges" directive. *) Feature: the module ngx_http_mp4_module. *) 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: in Linux AIO combined with open_file_cache. *) Bugfix: open_file_cache did not update file info on retest if file was not atomically changed. *) Bugfix: reduced memory consumption for long-lived requests. *) Bugfix: in the "proxy/fastcgi/scgi/uwsgi_ignore_client_abort" directives. *) Bugfix: nginx could not be built on MacOSX 10.7. *) Bugfix: in the "proxy/fastcgi/scgi/uwsgi_ignore_client_abort" directives. *) Bugfix: request body might be processed incorrectly if client used pipelining. *) Bugfix: in the "request_body_in_single_buf" directive. *) Bugfix: in "proxy_set_body" and "proxy_pass_request_body" directives if SSL connection to backend was used. *) Bugfix: nginx hogged CPU if all servers in an upstream were marked as "down". *) Bugfix: a segmentation fault might occur during reconfiguration if ssl_session_cache was defined but not used in previous configuration. *) Bugfix: a segmentation fault might occur in a worker process if many backup servers were used in an upstream.
author Igor Sysoev <http://sysoev.ru>
date Fri, 30 Sep 2011 00:00:00 +0400
parents c5122335e41d
children ad25218fd14b
comparison
equal deleted inserted replaced
633:7c3c34755d2e 634:0d6525917227
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) {
72 ngx_set_errno(0); 72 ngx_set_errno(0);
73 return aio->res; 73 return aio->res;
74 } 74 }
75 75
76 ngx_set_errno(-aio->res); 76 ngx_set_errno(-aio->res);
77
78 ngx_log_error(NGX_LOG_CRIT, file->log, ngx_errno,
79 "aio read \"%s\" failed", file->name.data);
80
77 return NGX_ERROR; 81 return NGX_ERROR;
78 } 82 }
79 83
80 ngx_memzero(&aio->aiocb, sizeof(struct iocb)); 84 ngx_memzero(&aio->aiocb, sizeof(struct iocb));
81 85
90 94
91 ev->handler = ngx_file_aio_event_handler; 95 ev->handler = ngx_file_aio_event_handler;
92 96
93 piocb[0] = &aio->aiocb; 97 piocb[0] = &aio->aiocb;
94 98
95 n = io_submit(ngx_aio_ctx, 1, piocb); 99 if (io_submit(ngx_aio_ctx, 1, piocb) == 1) {
96
97 if (n == 1) {
98 ev->active = 1; 100 ev->active = 1;
99 ev->ready = 0; 101 ev->ready = 0;
100 ev->complete = 0; 102 ev->complete = 0;
101 103
102 return NGX_AGAIN; 104 return NGX_AGAIN;
103 } 105 }
104 106
105 n = -n; 107 err = ngx_errno;
106 108
107 if (n == NGX_EAGAIN) { 109 if (err == NGX_EAGAIN) {
108 return ngx_read_file(file, buf, size, offset); 110 return ngx_read_file(file, buf, size, offset);
109 } 111 }
110 112
111 ngx_log_error(NGX_LOG_CRIT, file->log, n, 113 ngx_log_error(NGX_LOG_CRIT, file->log, err,
112 "io_submit(\"%V\") failed", &file->name); 114 "io_submit(\"%V\") failed", &file->name);
113 115
114 if (n == NGX_ENOSYS) { 116 if (err == NGX_ENOSYS) {
115 ngx_file_aio = 0; 117 ngx_file_aio = 0;
116 return ngx_read_file(file, buf, size, offset); 118 return ngx_read_file(file, buf, size, offset);
117 } 119 }
118 120
119 return NGX_ERROR; 121 return NGX_ERROR;