return htx_sl_p3(sl);
}
+/* Returns the HTX start-line if set, otherwise it returns NULL. */
+static inline struct htx_sl *htx_get_stline(struct htx *htx)
+{
+ struct htx_sl *sl = NULL;
+
+ if (htx->sl_off != -1)
+ sl = ((void *)htx->blocks + htx->sl_off);
+
+ return sl;
+}
+
/* Returns the array index of a block given its position <pos> */
static inline uint32_t htx_pos_to_idx(const struct htx *htx, uint32_t pos)
{
return ret;
}
+
/* Returns the value of the block <blk>, depending on its type. If there is no
* value, an empty one is retruned.
*/
htx->data = htx->used = htx->tail = htx->wrap = htx->front = 0;
htx->extra = 0;
htx->flags = HTX_FL_NONE;
+ htx->sl_off = -1;
}
/* Returns an HTX message using the buffer <buf>. */
new++;
addr += blksz;
+ /* update the start-line offset */
+ if (htx->sl_off == oldblk->addr)
+ htx->sl_off = addr;
+
/* if <blk> is defined, set its new location */
if (blk != NULL && blk == oldblk)
blk = newblk;
*/
struct htx_blk *htx_remove_blk(struct htx *htx, struct htx_blk *blk)
{
+ enum htx_blk_type type = htx_get_blk_type(blk);
uint32_t next, head, pos;
- if (htx_get_blk_type(blk) != HTX_BLK_UNUSED) {
+ if (type != HTX_BLK_UNUSED) {
/* Mark the block as unused, decrement allocated size */
htx->data -= htx_get_blksz(blk);
blk->info = ((uint32_t)HTX_BLK_UNUSED << 28);
+ if (htx->sl_off == blk->addr)
+ htx->sl_off = -1;
}
/* This is the last block in use */
}
blk = htx_get_blk(htx, next);
+ if (htx->sl_off == -1) {
+ /* Try to update the start-line offset, if possible */
+ type = htx_get_blk_type(blk);
+ if (type == HTX_BLK_REQ_SL || type == HTX_BLK_RES_SL)
+ htx->sl_off = blk->addr;
+ }
end:
if (pos == htx->front)
htx->front = htx_find_front(htx);
break;
}
+ if (dst->sl_off == -1 && src->sl_off == blk->addr)
+ dst->sl_off = dstblk->addr;
next:
blk = htx_remove_blk(src, blk);
if (type == mark)
htx_sl = htx_get_blk_ptr(htx, blk);
htx_sl->info.req.meth = sl.rq.meth;
+ if (htx->sl_off == -1)
+ htx->sl_off = blk->addr;
+
HTX_SL_REQ_MLEN(htx_sl) = sl.rq.m.len;
HTX_SL_REQ_ULEN(htx_sl) = sl.rq.u.len;
HTX_SL_REQ_VLEN(htx_sl) = sl.rq.v.len;
htx_sl = htx_get_blk_ptr(htx, blk);
htx_sl->info.res.status = sl.st.status;
+ if (htx->sl_off == -1)
+ htx->sl_off = blk->addr;
+
HTX_SL_RES_VLEN(htx_sl) = sl.st.v.len;
HTX_SL_RES_CLEN(htx_sl) = sl.st.c.len;
HTX_SL_RES_RLEN(htx_sl) = sl.st.r.len;
if (type != HTX_BLK_REQ_SL)
return NULL;
+ if (htx->sl_off == blk->addr)
+ htx->sl_off = -1;
+
size = sizeof(struct htx_sl) + sl.rq.m.len + sl.rq.u.len + sl.rq.v.len;
blk = htx_new_blk_value(htx, blk, size);
if (!blk)
if (type != HTX_BLK_RES_SL)
return NULL;
+ if (htx->sl_off == blk->addr)
+ htx->sl_off = -1;
+
size = sizeof(struct htx_sl) + sl.rq.m.len + sl.rq.u.len + sl.rq.v.len;
blk = htx_new_blk_value(htx, blk, size);
if (!blk)