]> git.ipfire.org Git - thirdparty/knot-resolver.git/commit
amend! daemon/session2: support multiple short-lived buffers docs-develop-nits-2dntdj/deployments/4198
authorOto Šťáva <oto.stava@nic.cz>
Tue, 28 May 2024 14:54:29 +0000 (16:54 +0200)
committerOto Šťáva <oto.stava@nic.cz>
Tue, 28 May 2024 14:54:29 +0000 (16:54 +0200)
commitbda116f92be14a530f0f739f26d1e5bad2bf1f69
tree3aab751a065874b96f2f423919e121b382547237
parentc2c69937f060e773a32a72fc4ec7ff335cb98820
amend! daemon/session2: support multiple short-lived buffers

daemon/session2: optimize context-specific allocations

There were two problems:

1) Some payloads are short-lived (e.g. allocated on stack) and we need
   to make a copy of them if the iteration over protocol layers becomes
   asynchronous.
2) The `pl_dns_stream_wrap` function used a mempool belonging to its
   session-wide context. Some sessions may live for a long time, which
   could potentially lead to needlessly long-lived memory allocations.

Both of these problems are solved in this commit by using a new
`knot_mm_t pool` field in `struct protolayer_iter_ctx`, which lives only
for a single submit (and survives asynchronicity). The whole pool is
then freed all at once when the `struct protolayer_iter_ctx` is
finalized.
daemon/session2.c
daemon/session2.h
daemon/worker.c