Klaus Demo nginx / f4d00a9
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. Maxim Dounin 8 years ago
2 changed file(s) with 13 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
189189
190190 rc = n;
191191
192 if (file->aio) {
192 if (rc == NGX_AGAIN) {
193193 file->aio->data = r;
194194 file->aio->handler = ngx_http_copy_aio_sendfile_event_handler;
195195
156156 return NGX_ERROR;
157157 }
158158
159 if (n != 0) {
160 if (n == NGX_EINPROGRESS) {
161 if (ev->ready) {
162 ev->ready = 0;
163 ngx_log_error(NGX_LOG_ALERT, file->log, n,
164 "aio_read(\"%V\") still in progress",
165 &file->name);
166 }
167
168 return NGX_AGAIN;
169 }
170
171 aio->err = n;
172 ev->ready = 0;
173
174 ngx_log_error(NGX_LOG_CRIT, file->log, n,
175 "aio_read(\"%V\") failed", &file->name);
176 return NGX_ERROR;
159 if (n == NGX_EINPROGRESS) {
160 if (ev->ready) {
161 ev->ready = 0;
162 ngx_log_error(NGX_LOG_ALERT, file->log, n,
163 "aio_read(\"%V\") still in progress",
164 &file->name);
165 }
166
167 return NGX_AGAIN;
177168 }
178169
179170 n = aio_return(&aio->aiocb);
181172 if (n == -1) {
182173 err = ngx_errno;
183174 aio->err = err;
184 ev->ready = 0;
185
186 ngx_log_error(NGX_LOG_ALERT, file->log, err,
175 ev->ready = 1;
176
177 ngx_log_error(NGX_LOG_CRIT, file->log, err,
187178 "aio_return(\"%V\") failed", &file->name);
188179 return NGX_ERROR;
189180 }