pkt-line: define PACKET_READ_RESPONSE_END

In a future commit, we will use PACKET_READ_RESPONSE_END to separate
messages proxied by remote-curl. To prepare for this, add the
PACKET_READ_RESPONSE_END enum value.

In switch statements that need a case added, die() or BUG() when a
PACKET_READ_RESPONSE_END is unexpected. Otherwise, mirror how
PACKET_READ_DELIM is implemented (especially in cases where packets are
being forwarded).

Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Denton Liu
2020-05-19 06:53:59 -04:00
committed by Junio C Hamano
parent 74b082ad34
commit 0181b600a6
6 changed files with 23 additions and 0 deletions

View File

@ -99,6 +99,13 @@ void packet_delim(int fd)
die_errno(_("unable to write delim packet"));
}
void packet_response_end(int fd)
{
packet_trace("0002", 4, 1);
if (write_in_full(fd, "0002", 4) < 0)
die_errno(_("unable to write stateless separator packet"));
}
int packet_flush_gently(int fd)
{
packet_trace("0000", 4, 1);
@ -337,6 +344,10 @@ enum packet_read_status packet_read_with_status(int fd, char **src_buffer,
packet_trace("0001", 4, 0);
*pktlen = 0;
return PACKET_READ_DELIM;
} else if (len == 2) {
packet_trace("0002", 4, 0);
*pktlen = 0;
return PACKET_READ_RESPONSE_END;
} else if (len < 4) {
die(_("protocol error: bad line length %d"), len);
}