diff options
author | Gleb Smirnoff <glebius@nginx.com> | 2013-08-08 15:06:39 +0400 |
---|---|---|
committer | Gleb Smirnoff <glebius@nginx.com> | 2013-08-08 15:06:39 +0400 |
commit | 65e37b4a128e5c4fe88721c790fd6f5c13102a62 (patch) | |
tree | 13df7393a0d4f489ca50b6541e49cfb7a6bf09bb /src/os/unix/ngx_linux_sendfile_chain.c | |
parent | be27365bb10e255330d3baeda2b918ea9fd79b8e (diff) | |
download | nginx-65e37b4a128e5c4fe88721c790fd6f5c13102a62.tar.gz nginx-65e37b4a128e5c4fe88721c790fd6f5c13102a62.zip |
Don't lose pointer to first nonempty buf in ngx_*_sendfile_chain().
In ngx_*_sendfile_chain() when calculating pointer to a first
non-zero sized buf, use "in" as iterator. This fixes processing
of zero sized buf(s) after EINTR. Otherwise function can return
zero sized buf to caller, and later ngx_http_write_filter()
logs warning.
Diffstat (limited to 'src/os/unix/ngx_linux_sendfile_chain.c')
-rw-r--r-- | src/os/unix/ngx_linux_sendfile_chain.c | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/src/os/unix/ngx_linux_sendfile_chain.c b/src/os/unix/ngx_linux_sendfile_chain.c index 643855ed9..8c4d59c22 100644 --- a/src/os/unix/ngx_linux_sendfile_chain.c +++ b/src/os/unix/ngx_linux_sendfile_chain.c @@ -325,9 +325,9 @@ ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit) c->sent += sent; - for (cl = in; cl; cl = cl->next) { + for ( /* void */ ; in; in = in->next) { - if (ngx_buf_special(cl->buf)) { + if (ngx_buf_special(in->buf)) { continue; } @@ -335,28 +335,28 @@ ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit) break; } - size = ngx_buf_size(cl->buf); + size = ngx_buf_size(in->buf); if (sent >= size) { sent -= size; - if (ngx_buf_in_memory(cl->buf)) { - cl->buf->pos = cl->buf->last; + if (ngx_buf_in_memory(in->buf)) { + in->buf->pos = in->buf->last; } - if (cl->buf->in_file) { - cl->buf->file_pos = cl->buf->file_last; + if (in->buf->in_file) { + in->buf->file_pos = in->buf->file_last; } continue; } - if (ngx_buf_in_memory(cl->buf)) { - cl->buf->pos += (size_t) sent; + if (ngx_buf_in_memory(in->buf)) { + in->buf->pos += (size_t) sent; } - if (cl->buf->in_file) { - cl->buf->file_pos += sent; + if (in->buf->in_file) { + in->buf->file_pos += sent; } break; @@ -368,13 +368,11 @@ ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit) if (!complete) { wev->ready = 0; - return cl; + return in; } - if (send >= limit || cl == NULL) { - return cl; + if (send >= limit || in == NULL) { + return in; } - - in = cl; } } |