summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_buf.c
diff options
context:
space:
mode:
authorAndrei Belov <defan@nginx.com>2019-11-14 19:29:00 +0300
committerAndrei Belov <defan@nginx.com>2019-11-14 19:29:00 +0300
commit7630539c44fcb188bba03a65af34e952a81f2f38 (patch)
tree2c80f0cd315cae8079a39ba98ed89e02b5e1931a /src/nxt_buf.c
parent70c9f18b6e8b25850bce8eb1edba4d100c3e55d2 (diff)
parent0a27f137de776925a24406cf6961c550824c63a0 (diff)
downloadunit-7630539c44fcb188bba03a65af34e952a81f2f38.tar.gz
unit-7630539c44fcb188bba03a65af34e952a81f2f38.tar.bz2
Merged with the default branch.1.13.0-1
Diffstat (limited to '')
-rw-r--r--src/nxt_buf.c48
1 files changed, 31 insertions, 17 deletions
diff --git a/src/nxt_buf.c b/src/nxt_buf.c
index 91846e4d..83be0fac 100644
--- a/src/nxt_buf.c
+++ b/src/nxt_buf.c
@@ -183,7 +183,10 @@ nxt_buf_chain_length(nxt_buf_t *b)
length = 0;
while (b != NULL) {
- length += b->mem.free - b->mem.pos;
+ if (!nxt_buf_is_sync(b)) {
+ length += b->mem.free - b->mem.pos;
+ }
+
b = b->next;
}
@@ -195,7 +198,7 @@ static void
nxt_buf_completion(nxt_task_t *task, void *obj, void *data)
{
nxt_mp_t *mp;
- nxt_buf_t *b, *parent;
+ nxt_buf_t *b, *next, *parent;
b = obj;
parent = data;
@@ -204,9 +207,23 @@ nxt_buf_completion(nxt_task_t *task, void *obj, void *data)
nxt_assert(data == b->parent);
- mp = b->data;
- nxt_mp_free(mp, b);
+ do {
+ next = b->next;
+ parent = b->parent;
+ mp = b->data;
+
+ nxt_mp_free(mp, b);
+ nxt_buf_parent_completion(task, parent);
+
+ b = next;
+ } while (b != NULL);
+}
+
+
+void
+nxt_buf_parent_completion(nxt_task_t *task, nxt_buf_t *parent)
+{
if (parent != NULL) {
nxt_debug(task, "parent retain:%uD", parent->retain);
@@ -255,7 +272,7 @@ static void
nxt_buf_ts_completion(nxt_task_t *task, void *obj, void *data)
{
nxt_mp_t *mp;
- nxt_buf_t *b, *parent;
+ nxt_buf_t *b, *next, *parent;
b = obj;
parent = data;
@@ -268,21 +285,18 @@ nxt_buf_ts_completion(nxt_task_t *task, void *obj, void *data)
nxt_assert(data == b->parent);
- mp = b->data;
- nxt_mp_free(mp, b);
- nxt_mp_release(mp);
+ do {
+ next = b->next;
+ parent = b->parent;
+ mp = b->data;
- if (parent != NULL) {
- nxt_debug(task, "parent retain:%uD", parent->retain);
+ nxt_mp_free(mp, b);
+ nxt_mp_release(mp);
- parent->retain--;
+ nxt_buf_parent_completion(task, parent);
- if (parent->retain == 0) {
- parent->mem.pos = parent->mem.free;
-
- parent->completion_handler(task, parent, parent->parent);
- }
- }
+ b = next;
+ } while (b != NULL);
}