From 174bfb163cd43a55e08036080d20b471d3dc5261 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Thu, 6 Dec 2018 14:31:12 +0100 Subject: [PATCH] BUG/MEDIUM: htx: Set the right start-line offset after a defrag The offset was always wrong after an HTX defragmentation because the wrong address was used and because the update could occcur several time on the same defragmentation. --- src/htx.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/htx.c b/src/htx.c index 1f0ebebc9..5ca7b7e63 100644 --- a/src/htx.c +++ b/src/htx.c @@ -28,6 +28,7 @@ struct htx_blk *htx_defrag(struct htx *htx, struct htx_blk *blk) struct htx_blk *newblk, *oldblk; uint32_t new, old; uint32_t addr, blksz; + int32_t sl_off = -1; if (!htx->used) return NULL; @@ -49,19 +50,20 @@ struct htx_blk *htx_defrag(struct htx *htx, struct htx_blk *blk) newblk->info = oldblk->info; blksz = htx_get_blksz(oldblk); + /* update the start-line offset */ + if (htx->sl_off == oldblk->addr) + sl_off = addr; + memcpy((void *)tmp->blocks + addr, htx_get_blk_ptr(htx, oldblk), blksz); new++; addr += blksz; - /* update the start-line offset */ - if (htx->sl_off == oldblk->addr) - htx->sl_off = addr; - /* if is defined, set its new location */ if (blk != NULL && blk == oldblk) blk = newblk; } while (new < htx->used); + htx->sl_off = sl_off; htx->wrap = htx->used; htx->front = htx->tail = new - 1; memcpy((void *)htx->blocks, (void *)tmp->blocks, htx->size);