Optimise memory usage in the DoH code and fix a hard-to-reproduce crash
This merge request optimises memory usage in the DoH code. In particular:
- It replaces ad-hoc buffer handling code with
isc_buffer_t
. That makes the code slightly more secure as well, asisc_buffer_t
incorporates some sanity checks; - It reduces memory consumption by allocating properly sized buffers instead of following the allocate-64k-if-in-doubt strategy;
- It changes the code in such a way that memory copying is avoided when possible.
The changes above revealed some problems in the DoH code and the unit test suite flaws, making the test suite complete faster and without slight hiccups, I have seen before (some test would hang for some time and then continue). In particular,
- Some edge-case bugs were uncovered and fixed because of the slight changes in the code timings;
- The unit tests logic was fixed (in particular, now the test suite tests DoH with quota properly).
Additionally to the above, it avoids unnecessary memory copying in the TLS stream code as well as optimises it for small write requests.
Closes:
Edited by Artem Boldariev