Re: [RFC 12/14] fetch-pack: do not printf after closing stdout
- From
Stefan Beller <sbeller@google.com>
- Date
- Jan 26, 2017, 00:50 UTC
- Message-ID
- <CAGZ79kb+VVQoimCDCxk1JPtVdDcS0vgi3NgVfo_aZ_=feed8Cw@mail.gmail.com>
- In-Reply-To
- <db1db5d0e5563464c09d1678234c9c5e8ae5b2f4.1485381677.git.jonathantanmy@google.com>
On Wed, Jan 25, 2017 at 2:03 PM, Jonathan Tan <jonathantanmy@google.com> wrote:
> In fetch-pack, during a stateless RPC, printf is invoked after stdout is > closed. Update the code to not do this, preserving the existing > behavior.
This seems to me as if it could go as an independent bugfix(?) or refactoring as this seems to be unclear from the code?
Show 46 quoted lines
>
> Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
> ---
> builtin/fetch-pack.c | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
> index ae073ab24..24af3b7c5 100644
> --- a/builtin/fetch-pack.c
> +++ b/builtin/fetch-pack.c
> @@ -191,10 +191,10 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
> printf("connectivity-ok\n");
> fflush(stdout);
> }
> - close(fd[0]);
> - close(fd[1]);
> - if (finish_connect(conn))
> - return 1;
> + if (finish_connect(conn)) {
> + ret = 1;
> + goto cleanup;
> + }
>
> ret = !ref;
>
> @@ -218,11 +218,17 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
> ret = 1;
> }
>
> + if (args.stateless_rpc)
> + goto cleanup;
> +
> while (ref) {
> printf("%s %s\n",
> oid_to_hex(&ref->old_oid), ref->name);
> ref = ref->next;
> }
>
> +cleanup:
> + close(fd[0]);
> + close(fd[1]);
> return ret;
> }
> --
> 2.11.0.483.g087da7b7c-goog
>