diff options
author | Oto Šťáva <oto.stava@nic.cz> | 2023-03-01 11:24:10 +0100 |
---|---|---|
committer | Oto Šťáva <oto.stava@nic.cz> | 2023-03-17 08:18:43 +0100 |
commit | 55a7fc96ba2cd91526c4352af8e2a8046943dd29 (patch) | |
tree | e07cc58f6af04c52c36ed9691bfc34194b0f6331 /daemon/session2.c | |
parent | daemon: refactor and documentation (diff) | |
download | knot-resolver-55a7fc96ba2cd91526c4352af8e2a8046943dd29.tar.xz knot-resolver-55a7fc96ba2cd91526c4352af8e2a8046943dd29.zip |
daemon: optimize memory consumption for outgoing UDP
Diffstat (limited to 'daemon/session2.c')
-rw-r--r-- | daemon/session2.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/daemon/session2.c b/daemon/session2.c index 85bbd22b..2bba4a22 100644 --- a/daemon/session2.c +++ b/daemon/session2.c @@ -576,6 +576,7 @@ static struct protolayer_manager *protolayer_manager_new( return NULL; size_t wire_buf_length = 0; + size_t wire_buf_max_length = 0; ssize_t offsets[2 * num_layers]; manager_size += sizeof(offsets); @@ -594,7 +595,11 @@ static struct protolayer_manager *protolayer_manager_new( iter_offsets[i] = g->iter_size ? total_iter_data_size : -1; total_iter_data_size += ALIGN_TO(g->iter_size, CPU_STRUCT_ALIGN); - wire_buf_length += g->wire_buf_overhead; + size_t wire_buf_overhead = (g->wire_buf_overhead_cb) + ? g->wire_buf_overhead_cb(s->outgoing) + : g->wire_buf_overhead; + wire_buf_length += wire_buf_overhead; + wire_buf_max_length += MAX(g->wire_buf_max_overhead, wire_buf_overhead); } manager_size += total_sess_data_size; cb_ctx_size += total_iter_data_size; @@ -608,6 +613,7 @@ static struct protolayer_manager *protolayer_manager_new( m->cb_ctx_size = cb_ctx_size; memcpy(m->data, offsets, sizeof(offsets)); + m->wire_buf_max_length = wire_buf_max_length; int ret = wire_buf_init(&m->wire_buf, wire_buf_length); kr_require(!ret); |