diff --git a/src/hq_interop.c b/src/hq_interop.c index 0bbf44c5a..690c13bad 100644 --- a/src/hq_interop.c +++ b/src/hq_interop.c @@ -8,6 +8,8 @@ #include #include #include +#include +#include static ssize_t hq_interop_rcv_buf(struct qcs *qcs, struct buffer *b, int fin) { @@ -110,6 +112,28 @@ static size_t hq_interop_snd_buf(struct qcs *qcs, struct buffer *buf, switch (btype) { case HTX_BLK_DATA: + if (unlikely(fsize == count && + !b_data(res) && + htx_nbblks(htx) == 1 && btype == HTX_BLK_DATA)) { + void *old_area = res->area; + + TRACE_DATA("perform zero-copy DATA transfer", QMUX_EV_STRM_SEND, + qcs->qcc->conn, qcs); + + /* remap MUX buffer to HTX area */ + *res = b_make(buf->area, buf->size, + sizeof(struct htx) + blk->addr, fsize); + + /* assign old MUX area to HTX buffer. */ + buf->area = old_area; + buf->data = buf->head = 0; + total += fsize; + + /* reload HTX with empty buffer. */ + *htx = *htx_from_buf(buf); + goto end; + } + if (fsize > count) fsize = count;