]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jc/fetch-progressive-stride'
authorJunio C Hamano <gitster@pobox.com>
Tue, 29 Mar 2011 21:09:08 +0000 (14:09 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 29 Mar 2011 21:09:08 +0000 (14:09 -0700)
* jc/fetch-progressive-stride:
  Fix potential local deadlock during fetch-pack

1  2 
builtin/fetch-pack.c

diff --combined builtin/fetch-pack.c
index 65a8727453320f68e1230f702392c5ca3bb76884,147d67dca447aa4afa1c829865af636753cacf31..85aff029b225c023f09fda635f16cc00a22ed7ca
@@@ -1,4 -1,4 +1,4 @@@
 -#include "cache.h"
 +#include "builtin.h"
  #include "refs.h"
  #include "pkt-line.h"
  #include "commit.h"
@@@ -9,7 -9,6 +9,7 @@@
  #include "fetch-pack.h"
  #include "remote.h"
  #include "run-command.h"
 +#include "transport.h"
  
  static int transfer_unpack_limit = -1;
  static int fetch_unpack_limit = -1;
@@@ -219,27 -218,18 +219,28 @@@ static void send_request(int fd, struc
                safe_write(fd, buf->buf, buf->len);
  }
  
 +static void insert_one_alternate_ref(const struct ref *ref, void *unused)
 +{
 +      rev_list_insert_ref(NULL, ref->old_sha1, 0, NULL);
 +}
 +
 +static void insert_alternate_refs(void)
 +{
 +      foreach_alt_odb(refs_from_alternate_cb, insert_one_alternate_ref);
 +}
 +
  #define INITIAL_FLUSH 16
+ #define PIPESAFE_FLUSH 32
  #define LARGE_FLUSH 1024
  
  static int next_flush(int count)
  {
-       if (count < INITIAL_FLUSH * 2)
-               count += INITIAL_FLUSH;
-       else if (count < LARGE_FLUSH)
+       int flush_limit = args.stateless_rpc ? LARGE_FLUSH : PIPESAFE_FLUSH;
+       if (count < flush_limit)
                count <<= 1;
        else
-               count += LARGE_FLUSH;
+               count += flush_limit;
        return count;
  }
  
@@@ -262,7 -252,6 +263,7 @@@ static int find_common(int fd[2], unsig
        marked = 1;
  
        for_each_ref(rev_list_insert_ref, NULL);
 +      insert_alternate_refs();
  
        fetching = 0;
        for ( ; refs ; refs = refs->next) {
@@@ -735,8 -724,7 +736,8 @@@ static struct ref *do_fetch_pack(int fd
                if (server_supports("no-done")) {
                        if (args.verbose)
                                fprintf(stderr, "Server supports no-done\n");
 -                      no_done = 1;
 +                      if (args.stateless_rpc)
 +                              no_done = 1;
                }
        }
        else if (server_supports("multi_ack")) {
@@@ -846,8 -834,6 +847,8 @@@ int cmd_fetch_pack(int argc, const cha
        char **pack_lockfile_ptr = NULL;
        struct child_process *conn;
  
 +      packet_trace_identity("fetch-pack");
 +
        nr_heads = 0;
        heads = NULL;
        for (i = 1; i < argc; i++) {