mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-03 18:52:04 +00:00
MINOR: mux-h2: force reads to be HTX-aligned in HTX mode
H2 has a 9-byte frame header, and HTX has a 40-byte frame header. By artificially advancing the Rx header and limiting the amount of bytes read to protect the end of the buffer, we can make the data payload perfectly aligned with HTX blocks and optimize the copy.
This commit is contained in:
parent
98de12a5d1
commit
2a59e87735
25
src/mux_h2.c
25
src/mux_h2.c
@ -2442,11 +2442,34 @@ static int h2_recv(struct h2c *h2c)
|
||||
}
|
||||
|
||||
do {
|
||||
max = buf->size - b_data(buf);
|
||||
int aligned = 0;
|
||||
|
||||
if (!b_data(buf) && (h2c->proxy->options2 & PR_O2_USE_HTX)) {
|
||||
/* HTX in use : try to pre-align the buffer like the
|
||||
* rxbufs will be to optimize memory copies. We'll make
|
||||
* sure that the frame header lands at the end of the
|
||||
* HTX block to alias it upon recv. We cannot use the
|
||||
* head because rcv_buf() will realign the buffer if
|
||||
* it's empty. Thus we cheat and pretend we already
|
||||
* have a few bytes there.
|
||||
*/
|
||||
max = buf_room_for_htx_data(buf) + 9;
|
||||
buf->head = 0;
|
||||
buf->data = sizeof(struct htx) - 9;
|
||||
aligned = 1;
|
||||
}
|
||||
else
|
||||
max = b_room(buf);
|
||||
|
||||
if (max)
|
||||
ret = conn->xprt->rcv_buf(conn, buf, max, 0);
|
||||
else
|
||||
ret = 0;
|
||||
|
||||
if (aligned) {
|
||||
buf->data -= sizeof(struct htx) - 9;
|
||||
buf->head = sizeof(struct htx) - 9;
|
||||
}
|
||||
} while (ret > 0);
|
||||
|
||||
if (h2_recv_allowed(h2c) && (b_data(buf) < buf->size))
|
||||
|
Loading…
Reference in New Issue
Block a user