pkt-line: eliminate the need for static buffer in packet_write_gently()
authorJeff Hostetler <jeffhost@microsoft.com>
Mon, 15 Mar 2021 21:08:18 +0000 (21:08 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 15 Mar 2021 21:32:50 +0000 (14:32 -0700)
commit7455e05e4e750451eb3c33359a2bc9050156750c
treefaec10acf177c9e72136242132e497ef82e4bc04
parent59ec22464f6c2b170b05f287e00740ea2288fe5c
pkt-line: eliminate the need for static buffer in packet_write_gently()

Teach `packet_write_gently()` to write the pkt-line header and the actual
buffer in 2 separate calls to `write_in_full()` and avoid the need for a
static buffer, thread-safe scratch space, or an excessively large stack
buffer.

Change `write_packetized_from_fd()` to allocate a temporary buffer rather
than using a static buffer to avoid similar issues here.

These changes are intended to make it easier to use pkt-line routines in
a multi-threaded context with multiple concurrent writers writing to
different streams.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pkt-line.c