Re: [PATCH v3 02/35] pkt-line: introduce struct packet_reader
From: Jonathan Nieder <hidden>
Date: 2018-02-27 06:13:02
Jonathan Nieder wrote:
Brandon Williams wrote:
quoted
Sometimes it is advantageous to be able to peek the next packet line without consuming it (e.g. to be able to determine the protocol version a server is speaking). In order to do that introduce 'struct packet_reader' which is an abstraction around the normal packet reading logic. This enables a caller to be able to peek a single line at a time using 'packet_reader_peek()' and having a caller consume a line by calling 'packet_reader_read()'. Signed-off-by: Brandon Williams <redacted> --- pkt-line.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ pkt-line.h | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+)I like it! The questions and nits from https://public-inbox.org/git/20180213004937.GB42272@aiede.svl.corp.google.com/ still apply. In particular, the ownership of the buffers inside the 'struct packet_reader' is still unclear; could the packet_reader create its own (strbuf) buffers so that the contract around them (who is allowed to write to them; who is responsible for freeing them) is more obvious?
Just to be clear: I sent that review after you sent this patch, so there should not have been any reason for me to expect the q's and nits to magically not apply. ;-)