diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2022-11-17 16:58:47 +1100 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2022-11-25 01:34:54 +0100 |
commit | 0eef48c4be5ae8d9de5fed4daaa1954323e08b96 (patch) | |
tree | 6bc82f285ce1eb1959c0282346b403f1013e3d6a /tcp.c | |
parent | ee8f8e9564c5bd0ca25a9492e3102655d9ce0620 (diff) | |
download | passt-0eef48c4be5ae8d9de5fed4daaa1954323e08b96.tar passt-0eef48c4be5ae8d9de5fed4daaa1954323e08b96.tar.gz passt-0eef48c4be5ae8d9de5fed4daaa1954323e08b96.tar.bz2 passt-0eef48c4be5ae8d9de5fed4daaa1954323e08b96.tar.lz passt-0eef48c4be5ae8d9de5fed4daaa1954323e08b96.tar.xz passt-0eef48c4be5ae8d9de5fed4daaa1954323e08b96.tar.zst passt-0eef48c4be5ae8d9de5fed4daaa1954323e08b96.zip |
tcp: Unify tcp_defer_handler and tcp_splice_defer_handler()
These two functions each step through non-spliced and spliced connections
respectively and clean up entries for closed connections. To avoid
scanning the connection table twice, we merge these into a single function
which scans the unified table and performs the appropriate sort of cleanup
action on each one.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'tcp.c')
-rw-r--r-- | tcp.c | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -1527,21 +1527,23 @@ void tcp_defer_handler(struct ctx *c) { int max_conns = c->tcp.conn_count / 100 * TCP_CONN_PRESSURE; int max_files = c->nofile / 100 * TCP_FILE_PRESSURE; - struct tcp_tap_conn *conn; + union tcp_conn *conn; tcp_l2_flags_buf_flush(c); tcp_l2_data_buf_flush(c); - tcp_splice_defer_handler(c); - - if (c->tcp.conn_count < MIN(max_files, max_conns)) + if ((c->tcp.conn_count < MIN(max_files, max_conns)) && + (c->tcp.splice_conn_count < MIN(max_files / 6, max_conns))) return; - for (conn = CONN(c->tcp.conn_count - 1); conn >= CONN(0); conn--) { - if (conn->c.spliced) - continue; - if (conn->events == CLOSED) - tcp_conn_destroy(c, conn); + for (conn = tc + c->tcp.conn_count - 1; conn >= tc; conn--) { + if (conn->c.spliced) { + if (conn->splice.flags & CLOSING) + tcp_splice_destroy(c, &conn->splice); + } else { + if (conn->tap.events == CLOSED) + tcp_conn_destroy(c, &conn->tap); + } } } |