diff options
author | Valentin Bartenev <vbart@nginx.com> | 2014-08-13 15:11:45 +0400 |
---|---|---|
committer | Valentin Bartenev <vbart@nginx.com> | 2014-08-13 15:11:45 +0400 |
commit | 4aac91049f8909e928580f9fb8b752ba748f4167 (patch) | |
tree | 3100acd79e0cf9e317878113207b0e942705a88c /src/core | |
parent | 8b6f1c7bb064aa87ab83fbf3d8ed9f9e80e1b06b (diff) |
Moved the code for adjusting sent buffers in a separate function.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/ngx_buf.c | 46 | ||||
-rw-r--r-- | src/core/ngx_buf.h | 1 |
2 files changed, 47 insertions, 0 deletions
diff --git a/src/core/ngx_buf.c b/src/core/ngx_buf.c index 835c76ced..94a3d3f10 100644 --- a/src/core/ngx_buf.c +++ b/src/core/ngx_buf.c @@ -218,3 +218,49 @@ ngx_chain_update_chains(ngx_pool_t *p, ngx_chain_t **free, ngx_chain_t **busy, *free = cl; } } + + +ngx_chain_t * +ngx_handle_sent_chain(ngx_chain_t *in, off_t sent) +{ + off_t size; + + for ( /* void */ ; in; in = in->next) { + + if (ngx_buf_special(in->buf)) { + continue; + } + + if (sent == 0) { + break; + } + + size = ngx_buf_size(in->buf); + + if (sent >= size) { + sent -= size; + + if (ngx_buf_in_memory(in->buf)) { + in->buf->pos = in->buf->last; + } + + if (in->buf->in_file) { + in->buf->file_pos = in->buf->file_last; + } + + continue; + } + + if (ngx_buf_in_memory(in->buf)) { + in->buf->pos += (size_t) sent; + } + + if (in->buf->in_file) { + in->buf->file_pos += sent; + } + + break; + } + + return in; +} diff --git a/src/core/ngx_buf.h b/src/core/ngx_buf.h index ffc531094..cc28a3e15 100644 --- a/src/core/ngx_buf.h +++ b/src/core/ngx_buf.h @@ -158,5 +158,6 @@ ngx_chain_t *ngx_chain_get_free_buf(ngx_pool_t *p, ngx_chain_t **free); void ngx_chain_update_chains(ngx_pool_t *p, ngx_chain_t **free, ngx_chain_t **busy, ngx_chain_t **out, ngx_buf_tag_t tag); +ngx_chain_t *ngx_handle_sent_chain(ngx_chain_t *in, off_t sent); #endif /* _NGX_BUF_H_INCLUDED_ */ |