Skip to content

Commit

Permalink
http-push: fix webdav lock leak.
Browse files Browse the repository at this point in the history
Releasing webdav lock even if push fails because of bad (or no)
reference on command line.

To reproduce the issue that this patch fixes, prepare a test repository
availlable over http+webdav, say at http://myhost/myrepo.git/

Then:

  $ 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's 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�.A�Nigoire Barbier <gb@gbarbier.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Grégoire Barbier authored and Junio C Hamano committed Jan 20, 2008
1 parent 0a61779 commit 9116de5
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions http-push.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 9116de5

Please sign in to comment.