git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
>
Previous: Jonathan TanNext: Jonathan Tan
Message 8 of 30 in “[RFC 00/14] Allow fetch-pack to send ref names (globs allowed)”
  1. Jonathan TanJan 25, 2017
  2. 02/14 upload-pack: allow ref name and glob requestsJonathan Tan, Jan 25, 2017
  3. Junio C HamanoJan 26, 2017
  4. Jonathan TanJan 27, 2017
  5. Junio C HamanoJan 27, 2017
  6. 01/14 upload-pack: move parsing of "want" lineJonathan Tan, Jan 25, 2017
  7. 12/14 fetch-pack: do not printf after closing stdoutJonathan Tan, Jan 25, 2017
  8. Stefan BellerJan 26, 2017
  9. Jonathan TanJan 26, 2017
  10. 13/14 fetch: send want-ref and receive fetched refsJonathan Tan, Jan 25, 2017
  11. 04/14 fetch: refactor the population of hashesJonathan Tan, Jan 25, 2017
  12. 03/14 upload-pack: test negotiation with changing repoJonathan Tan, Jan 25, 2017
  13. Junio C HamanoJan 26, 2017
  14. Jonathan TanJan 27, 2017
  15. Junio C HamanoFeb 22, 2017
  16. upload-pack: report "not our ref" to clientJonathan Tan, Feb 23, 2017
  17. Junio C HamanoFeb 23, 2017
  18. 11/14 fetch-pack: support want-refJonathan Tan, Jan 25, 2017
  19. 07/14 fetch-pack: put shallow info in out paramJonathan Tan, Jan 25, 2017
  20. 14/14 DONT USE advertise_ref_in_want=1Jonathan Tan, Jan 25, 2017
  21. 05/14 fetch: refactor fetch_refs into two functionsJonathan Tan, Jan 25, 2017
  22. 06/14 fetch: refactor to make function args narrowerJonathan Tan, Jan 25, 2017
  23. 09/14 transport: put ref oid in out paramJonathan Tan, Jan 25, 2017
  24. 08/14 fetch-pack: check returned refs for matchesJonathan Tan, Jan 25, 2017
  25. 10/14 fetch-pack: support partial names and globsJonathan Tan, Jan 25, 2017
  26. Stefan BellerJan 26, 2017
  27. Jeff KingJan 26, 2017
  28. Jonathan TanJan 27, 2017
  29. Jonathan TanFeb 7, 2017
  30. Junio C HamanoFeb 9, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.