[9.18] Use appropriately sized send buffers for DNS messages over TCP
requested to merge 4038-resize-send-buffers-to-avoid-excessive-memory-allocation-9.18 into bind-9.18
This commit changes send buffers allocation strategy for stream based transports. Before that change we would allocate a dynamic buffers sized at 64Kb even when we do not need that much. That could lead to high memory usage on server. Now we resize the send buffer to match the size of the actual data, freeing the memory at the end of the buffer for being reused later.
(cherry picked from commit d8a5feb5)
Closes #4038 (closed)
Backport of MR !8004 (merged)
Edited by Ondřej Surý