Re: [PATCH v2 2/8] odb/streaming: drop `is_finished` field

Karthik Nayak <[email protected]>
Newsgroups org.kernel.vger.git
Message-ID <CAOLa=ZQtdUKeuhNbxLC3kBTT9JbxgM8wJUGCzPNKJmEEscA4TA@mail.gmail.com>
Patrick Steinhardt <[email protected]> writes:

[snip]

> diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
> index f3e0b504f4..b7c486ea94 100644
> --- a/builtin/unpack-objects.c
> +++ b/builtin/unpack-objects.c
> @@ -368,20 +368,20 @@ static ssize_t feed_input_zstream(struct odb_write_stream *in_stream,
>  {
>  	struct input_zstream_data *data = in_stream->data;
>  	git_zstream *zstream = data->zstream;
> -	void *in = fill(1);
>
> -	if (in_stream->is_finished)
> +	if (data->status != Z_OK)
>  		return 0;
>
>  	zstream->next_out = buf;
>  	zstream->avail_out = buf_len;
> -	zstream->next_in = in;
> -	zstream->avail_in = len;
>
> -	data->status = git_inflate(zstream, 0);
> +	while (data->status == Z_OK && zstream->avail_out == buf_len) {
> +		zstream->next_in = fill(1);
> +		zstream->avail_in = len;
> +		data->status = git_inflate(zstream, 0);
> +		use(len - zstream->avail_in);
> +	}
>
> -	in_stream->is_finished = data->status != Z_OK;
> -	use(len - zstream->avail_in);
>  	return buf_len - zstream->avail_out;
>  }
>

So we have a bunch of global variables used for zstream parsing. The
loop ensures that we keep trying until we get some data. The use()
function manipulate `len` accordingly for the next iteration..

[snip]
signature.asc (application/pgp-signature, 690 B)
-----BEGIN PGP SIGNATURE-----

iQHKBAEBCgA0FiEEV85Mf2N1cQ/LZcYGPtWfJI5GjH8FAmp68y8WHGthcnRoaWsu
MTg4QGdtYWlsLmNvbQAKCRA+1Z8kjkaMf0bYC/4ijldKnWuMF7pbnLNsLXyy49+4
9UGz9ZXQtA9qhyzgT5t8CiJGkqRR8PXn6Sg7+cfV7fDdWNwsWjFeTuYUQk8RocK7
XJ8F0EBifqv9hQFcl36aoZBYMZGt37MONZ19LRLKakKI/MsWCqI5VeNLJsoJCtLt
+0aPNzUaa/7paLERrEpk3dqGUpe3J1NlZWY0jPZyr0E4mUx+YbPuUoq7ZaRQtIuH
0VSLk898RhMXwMZpa2RITXhOzOCFmPozLvnQ8yfg/dkwxJ3a7oxVhggIEjfDzfb6
KzLzd8LQXA7fMrMAf19PP573+JAZW+2eVUChmCMPjujjkFenm9ps3NIlYjVmGInO
LTqUqQH+uJ4KBSXJ8133wjcKARF5sf5+Y1xrG5dgDb3Wc2fKWsak8Rygq5Rlo7Gp
dAHyiCQC88RpCeDxCndBndfCtSQw0n+GLmDxnnmiSv/RQocIowZFi3XyioGDahhd
l33OOl6zp2zj27VRB4kpc1F/jlrMqV+suxl9XyI=
=uTBr
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.