comparison src/os/unix/ngx_file_aio_read.c @ 4451:aaeb1b2dcbf3 stable-1.0

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.
author Maxim Dounin <mdounin@mdounin.ru>
date Sun, 05 Feb 2012 20:05:11 +0000
parents 4919fb357a5d
children ccad84a174e0
comparison
equal deleted inserted replaced
4450:4919fb357a5d 4451:aaeb1b2dcbf3
155 ngx_log_error(NGX_LOG_ALERT, file->log, err, 155 ngx_log_error(NGX_LOG_ALERT, file->log, err,
156 "aio_error(\"%V\") failed", &file->name); 156 "aio_error(\"%V\") failed", &file->name);
157 return NGX_ERROR; 157 return NGX_ERROR;
158 } 158 }
159 159
160 if (n != 0) { 160 if (n == NGX_EINPROGRESS) {
161 if (n == NGX_EINPROGRESS) { 161 if (ev->ready) {
162 if (ev->ready) { 162 ev->ready = 0;
163 ev->ready = 0; 163 ngx_log_error(NGX_LOG_ALERT, file->log, n,
164 ngx_log_error(NGX_LOG_ALERT, file->log, n, 164 "aio_read(\"%V\") still in progress",
165 "aio_read(\"%V\") still in progress", 165 &file->name);
166 &file->name); 166 }
167 } 167
168 168 return NGX_AGAIN;
169 return NGX_AGAIN;
170 }
171
172 aio->err = n;
173 ev->ready = 0;
174
175 ngx_log_error(NGX_LOG_CRIT, file->log, n,
176 "aio_read(\"%V\") failed", &file->name);
177 return NGX_ERROR;
178 } 169 }
179 170
180 n = aio_return(&aio->aiocb); 171 n = aio_return(&aio->aiocb);
181 172
182 if (n == -1) { 173 if (n == -1) {
183 err = ngx_errno; 174 err = ngx_errno;
184 aio->err = err; 175 aio->err = err;
185 ev->ready = 0; 176 ev->ready = 1;
186 177
187 ngx_log_error(NGX_LOG_ALERT, file->log, err, 178 ngx_log_error(NGX_LOG_CRIT, file->log, err,
188 "aio_return(\"%V\") failed", &file->name); 179 "aio_return(\"%V\") failed", &file->name);
189 return NGX_ERROR; 180 return NGX_ERROR;
190 } 181 }
191 182
192 aio->err = 0; 183 aio->err = 0;