threads / patch / 11873

patch, 2 partsClean up connection correctly if object fetch wasn't done

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

## tl;dr

4 messages between Feb 4, 2008 and Feb 4, 2008. Diffs are folded; open one to read it.

replies: 3people: 2as markdown or json

Daniel Barkalow· Feb 4, 2008, 18:26 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>
---
 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
Johannes Schindelin· Feb 4, 2008, 20:23 UTC · re: Daniel Barkalow · lore

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

Hi,
On Mon, 4 Feb 2008, Daniel Barkalow wrote:
> 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.

I _think_ something similar is necessary for ls-remote, too (at least it showed the same symptoms today, but I have not had time to investigate yet).

Ciao, Dscho

Daniel Barkalow· Feb 4, 2008, 21:06 UTC · re: Johannes Schindelin · lore

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

On Mon, 4 Feb 2008, Johannes Schindelin wrote:
Show 12 quoted lines
> Hi,
> 
> On Mon, 4 Feb 2008, Daniel Barkalow wrote:
> 
> > 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.
> 
> I _think_ something similar is necessary for ls-remote, too (at least it 
> showed the same symptoms today, but I have not had time to investigate 
> yet).

Yup, exactly the same change to builtin-ls-remote that builtin-fetch needed.

Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
Show changes to builtin-ls-remote.c +1 −0
diff --git a/builtin-ls-remote.c b/builtin-ls-remote.c
index 6dd31d1..0237549 100644
--- a/builtin-ls-remote.c
+++ b/builtin-ls-remote.c
@@ -94,6 +94,7 @@ int cmd_ls_remote(int argc, const char **argv, const 
char *prefix)
                transport_set_option(transport, TRANS_OPT_UPLOADPACK, 
uploadpack);
 
        ref = transport_get_remote_refs(transport);
+       transport_disconnect(transport);
 
        if (!ref)
                return 1;
Johannes Schindelin· Feb 4, 2008, 21:21 UTC · re: Daniel Barkalow · lore

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

Hi,
On Mon, 4 Feb 2008, Daniel Barkalow wrote:
Show 15 quoted lines
> On Mon, 4 Feb 2008, Johannes Schindelin wrote:
> 
> > On Mon, 4 Feb 2008, Daniel Barkalow wrote:
> > 
> > > 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.
> > 
> > I _think_ something similar is necessary for ls-remote, too (at least 
> > it showed the same symptoms today, but I have not had time to 
> > investigate yet).
> 
> Yup, exactly the same change to builtin-ls-remote that builtin-fetch 
> needed.
Thanks, works here.

Ciao, Dscho

← back to recent threads