git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] http-push: fix webdav lock leak.
@ 2008-01-19 15:22 Grégoire Barbier
  2008-01-19 15:22 ` [PATCH] http-push: fail when info/refs exists and is already locked Grégoire Barbier
  2008-01-19 23:08 ` [PATCH] http-push: fix webdav lock leak Johannes Schindelin
  0 siblings, 2 replies; 13+ messages in thread
From: Grégoire Barbier @ 2008-01-19 15:22 UTC (permalink / raw)
  To: git; +Cc: gitster, Grégoire Barbier

Releasing webdav lock even if push fails because of bad (or no) reference
on command line.

To reproduce the issue that this patch fixes, you need a test git repository
availlable over http+webdav, let's say at http://myhost/myrepo.git/
Then, you do this:
$ git clone http://myhost/myrepo.git/
$ cd myrepo
$ git push http
Fetching remote heads...
  refs/
  refs/heads/
  refs/tags/
No refs in common and none specified; doing nothing.
$ git push http
Fetching remote heads...
  refs/
  refs/heads/
  refs/tags/
No refs in common and none specified; doing nothing.
$

Finally, you look at the web server logs, and will find one LOCK query and no
UNLOCK query, of course the second one will be in 423 return code instead of
200:
1.2.3.4 - gb [19/Jan/2008:14:24:56 +0100] "LOCK /myrepo.git/info/refs HTTP/1.1" 200 465
(...)
1.2.3.4 - gb [19/Jan/2008:14:25:10 +0100] "LOCK /myrepo.git/info/refs HTTP/1.1" 423 363

With this patch, there would have be two UNLOCKs in addition of the LOCKs

From the user point of view:
- If you realize that you should have typed e.g. "git push http master"
instead of "git push http", you will have to wait for 10 minutes for the lock
to expire by its own.
- Furthermore, if somebody else is dumb enough to type "git push http" while
you need to push "master" branch, then you'll need too to wait for 10 minutes
too.

Signed-off-by: Grégoire Barbier <gb@gbarbier.org>
---
 http-push.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/http-push.c b/http-push.c
index eef7674..2c4e91d 100644
--- a/http-push.c
+++ b/http-push.c
@@ -2264,11 +2264,14 @@ int main(int argc, char **argv)
 	if (!remote_tail)
 		remote_tail = &remote_refs;
 	if (match_refs(local_refs, remote_refs, &remote_tail,
-		       nr_refspec, (const char **) refspec, push_all))
-		return -1;
+		       nr_refspec, (const char **) refspec, push_all)) {
+		rc = -1;
+		goto cleanup;
+	}
 	if (!remote_refs) {
 		fprintf(stderr, "No refs in common and none specified; doing nothing.\n");
-		return 0;
+		rc = 0;
+		goto cleanup;
 	}
 
 	new_refs = 0;
@@ -2399,10 +2402,10 @@ int main(int argc, char **argv)
 			fprintf(stderr, "Unable to update server info\n");
 		}
 	}
-	if (info_ref_lock)
-		unlock_remote(info_ref_lock);
 
  cleanup:
+	if (info_ref_lock)
+		unlock_remote(info_ref_lock);
 	free(remote);
 
 	curl_slist_free_all(no_pragma_header);
-- 
1.5.4.rc3.52.g9a5bd-dirty

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2008-01-21 10:19 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-19 15:22 [PATCH] http-push: fix webdav lock leak Grégoire Barbier
2008-01-19 15:22 ` [PATCH] http-push: fail when info/refs exists and is already locked Grégoire Barbier
2008-01-19 15:22   ` [PATCH] http-push: more explicit error message with bad URL or password Grégoire Barbier
2008-01-19 15:22     ` [PATCH] http-push and http-fetch: handle URLs without leading / Grégoire Barbier
2008-01-19 15:22       ` [PATCH] added #define DEFAULT_MAX_REQUESTS for USE_CURL_MULTI mode Grégoire Barbier
2008-01-21  0:13         ` Junio C Hamano
2008-01-21  9:57           ` Grégoire Barbier
2008-01-21 10:19             ` Junio C Hamano
2008-01-19 15:29       ` [PATCH] http-push and http-fetch: handle URLs without leading / Mike Hommey
2008-01-19 23:16         ` Johannes Schindelin
2008-01-19 23:14       ` Johannes Schindelin
2008-01-20 23:00     ` [PATCH] http-push: more explicit error message with bad URL or password Junio C Hamano
2008-01-19 23:08 ` [PATCH] http-push: fix webdav lock leak Johannes Schindelin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).