comparison src/http/ngx_http_copy_filter_module.c @ 4195:35f4997c08ce

Fix for socket leak with "aio sendfile" and "limit_rate". Second aio post happened when timer set by limit_rate expired while we have aio request in flight, resulting in "second aio post" alert and socket leak. The patch adds actual protection from aio calls with r->aio already set to aio sendfile code in ngx_http_copy_filter(). This should fix other cases as well, e.g. when sending buffered to disk upstream replies while still talking to upstream. The ngx_http_writer() is also fixed to handle the above case (though it's mostly optimization now). Reported by Oleksandr V. Typlyns'kyi.
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 11 Oct 2011 18:00:23 +0000
parents d29e8060ca0c
children d620f497c50f
comparison
equal deleted inserted replaced
4194:7ce8f2cde0af 4195:35f4997c08ce
156 ssize_t n; 156 ssize_t n;
157 off_t offset; 157 off_t offset;
158 ngx_file_t *file; 158 ngx_file_t *file;
159 ngx_http_ephemeral_t *e; 159 ngx_http_ephemeral_t *e;
160 160
161 if (r->aio) {
162 c->busy_sendfile = NULL;
163 return rc;
164 }
165
161 file = c->busy_sendfile->file; 166 file = c->busy_sendfile->file;
162 offset = c->busy_sendfile->file_pos; 167 offset = c->busy_sendfile->file_pos;
163 168
164 if (file->aio) { 169 if (file->aio) {
165 c->aio_sendfile = (offset != file->aio->last_offset); 170 c->aio_sendfile = (offset != file->aio->last_offset);