threads / patch / 11753

patchClean up connection correctly if object fetch wasn't done

Subject: [PATCH] Clean up connection correctly if object fetch wasn't done

## tl;dr

2 messages between Jan 26, 2008 and Jan 26, 2008. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Daniel Barkalow· Jan 26, 2008, 21:49 UTC · lore

Further optimization allowed the fetch_objs call to be skipped if it isn't necessary. However, this leaves the connection in need of cleaning up to avoid getting an error message from the remote end when ssh is used. Fix this.

Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
---
This fixes the "fatal: The remote end hung up unexpectedly" message in the 
case I reproduced. It should probably get squashed into the other 
single-connect commit, but I'm sending it separately for easier testing 
for now.
 builtin-fetch.c |    2 ++
 transport.c     |   10 +++++++++-
 2 files changed, 11 insertions(+), 1 deletions(-)
Show changes to 2 files +11 −1

builtin-fetch.c, transport.c

diff --git a/builtin-fetch.c b/builtin-fetch.c
index 320e235..ac335f2 100644
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
@@ -557,6 +557,8 @@ static int do_fetch(struct transport *transport,
 
 	free_refs(fetch_map);
 
+	transport_disconnect(transport);
+
 	return 0;
 }
 
diff --git a/transport.c b/transport.c
index 53fb2ec..199e9e6 100644
--- a/transport.c
+++ b/transport.c
@@ -677,7 +677,15 @@ static int git_transport_push(struct transport *transport, int refspec_nr, const
 
 static int disconnect_git(struct transport *transport)
 {
-	free(transport->data);
+	struct git_transport_data *data = transport->data;
+	if (data->conn) {
+		packet_flush(data->fd[1]);
+		close(data->fd[0]);
+		close(data->fd[1]);
+		finish_connect(data->conn);
+	}
+
+	free(data);
 	return 0;
 }
 
-- 
1.5.4.rc3.4.g16335
Johannes Schindelin· Jan 26, 2008, 22:06 UTC · re: Daniel Barkalow · lore

Re: [PATCH] Clean up connection correctly if object fetch wasn't done

Hi,
On Sat, 26 Jan 2008, Daniel Barkalow wrote:
Show 11 quoted lines
> Further optimization allowed the fetch_objs call to be skipped if it 
> isn't necessary. However, this leaves the connection in need of cleaning 
> up to avoid getting an error message from the remote end when ssh is 
> used. Fix this.
> 
> Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
> ---
> This fixes the "fatal: The remote end hung up unexpectedly" message in the 
> case I reproduced. It should probably get squashed into the other 
> single-connect commit, but I'm sending it separately for easier testing 
> for now.
Yeah, that fixes it.  Thanks.
Show 20 quoted lines
> diff --git a/transport.c b/transport.c
> index 53fb2ec..199e9e6 100644
> --- a/transport.c
> +++ b/transport.c
> @@ -677,7 +677,15 @@ static int git_transport_push(struct transport *transport, int refspec_nr, const
>  
>  static int disconnect_git(struct transport *transport)
>  {
> -	free(transport->data);
> +	struct git_transport_data *data = transport->data;
> +	if (data->conn) {
> +		packet_flush(data->fd[1]);
> +		close(data->fd[0]);
> +		close(data->fd[1]);
> +		finish_connect(data->conn);
> +	}
> +
> +	free(data);
>  	return 0;
>  }
Should this not set transport->data = NULL, just to be sure?

Ciao, Dscho

← back to recent threads