Skip to content

Optimise memory usage in the DoH code and fix a hard-to-reproduce crash

Artem Boldariev requested to merge artem/doh-mem-alloc-optimisations into main

This merge request optimises memory usage in the DoH code. In particular:

  1. It replaces ad-hoc buffer handling code with isc_buffer_t. That makes the code slightly more secure as well, as isc_buffer_t incorporates some sanity checks;
  2. It reduces memory consumption by allocating properly sized buffers instead of following the allocate-64k-if-in-doubt strategy;
  3. 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,

  1. Some edge-case bugs were uncovered and fixed because of the slight changes in the code timings;
  2. 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

Merge request reports