{"thread":{"id":"11753","subject":"[PATCH] Clean up connection correctly if object fetch wasn't done","startedAt":"2008-01-26T21:49:25Z","lastAt":"2008-01-26T22:06:26Z","messageCount":2,"participants":["Daniel Barkalow","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"66649","messageId":"alpine.LNX.1.00.0801261647310.13593@iabervon.org","threadId":"11753","inReplyTo":null,"subject":"[PATCH] Clean up connection correctly if object fetch wasn't done","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2008-01-26T21:49:25Z","receivedAt":"2008-01-26T21:49:25Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"Further optimization allowed the fetch_objs call to be skipped if it\nisn't necessary. However, this leaves the connection in need of\ncleaning up to avoid getting an error message from the remote end when\nssh is used. Fix this.\n\nSigned-off-by: Daniel Barkalow <barkalow@iabervon.org>\n---\nThis fixes the \"fatal: The remote end hung up unexpectedly\" message in the \ncase I reproduced. It should probably get squashed into the other \nsingle-connect commit, but I'm sending it separately for easier testing \nfor now.\n\n builtin-fetch.c |    2 ++\n transport.c     |   10 +++++++++-\n 2 files changed, 11 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-fetch.c b/builtin-fetch.c\nindex 320e235..ac335f2 100644\n--- a/builtin-fetch.c\n+++ b/builtin-fetch.c\n@@ -557,6 +557,8 @@ static int do_fetch(struct transport *transport,\n \n \tfree_refs(fetch_map);\n \n+\ttransport_disconnect(transport);\n+\n \treturn 0;\n }\n \ndiff --git a/transport.c b/transport.c\nindex 53fb2ec..199e9e6 100644\n--- a/transport.c\n+++ b/transport.c\n@@ -677,7 +677,15 @@ static int git_transport_push(struct transport *transport, int refspec_nr, const\n \n static int disconnect_git(struct transport *transport)\n {\n-\tfree(transport->data);\n+\tstruct git_transport_data *data = transport->data;\n+\tif (data->conn) {\n+\t\tpacket_flush(data->fd[1]);\n+\t\tclose(data->fd[0]);\n+\t\tclose(data->fd[1]);\n+\t\tfinish_connect(data->conn);\n+\t}\n+\n+\tfree(data);\n \treturn 0;\n }\n \n-- \n1.5.4.rc3.4.g16335\n"},{"id":"66650","messageId":"alpine.LSU.1.00.0801262205130.23907@racer.site","threadId":"11753","inReplyTo":"alpine.LNX.1.00.0801261647310.13593@iabervon.org","subject":"Re: [PATCH] Clean up connection correctly if object fetch wasn't done","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-01-26T22:06:26Z","receivedAt":"2008-01-26T22:06:26Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 26 Jan 2008, Daniel Barkalow wrote:\n\n> Further optimization allowed the fetch_objs call to be skipped if it \n> isn't necessary. However, this leaves the connection in need of cleaning \n> up to avoid getting an error message from the remote end when ssh is \n> used. Fix this.\n> \n> Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>\n> ---\n> This fixes the \"fatal: The remote end hung up unexpectedly\" message in the \n> case I reproduced. It should probably get squashed into the other \n> single-connect commit, but I'm sending it separately for easier testing \n> for now.\n\nYeah, that fixes it.  Thanks.\n\n> diff --git a/transport.c b/transport.c\n> index 53fb2ec..199e9e6 100644\n> --- a/transport.c\n> +++ b/transport.c\n> @@ -677,7 +677,15 @@ static int git_transport_push(struct transport *transport, int refspec_nr, const\n>  \n>  static int disconnect_git(struct transport *transport)\n>  {\n> -\tfree(transport->data);\n> +\tstruct git_transport_data *data = transport->data;\n> +\tif (data->conn) {\n> +\t\tpacket_flush(data->fd[1]);\n> +\t\tclose(data->fd[0]);\n> +\t\tclose(data->fd[1]);\n> +\t\tfinish_connect(data->conn);\n> +\t}\n> +\n> +\tfree(data);\n>  \treturn 0;\n>  }\n\nShould this not set transport->data = NULL, just to be sure?\n\nCiao,\nDscho\n"}]}