diff src/core/ngx_buf.c @ 5850:f9c83484d9ce

Moved the code for adjusting sent buffers in a separate function.
author Valentin Bartenev <vbart@nginx.com>
date Wed, 13 Aug 2014 15:11:45 +0400
parents d620f497c50f
children de68ed551bfb
line wrap: on
line diff
--- a/src/core/ngx_buf.c
+++ b/src/core/ngx_buf.c
@@ -218,3 +218,49 @@ ngx_chain_update_chains(ngx_pool_t *p, n
         *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;
+}