fetch-pack: give up after getting too many "ack continue"
If your repository have more roots than the remote repository you ask an object for, the remote upload-pack keeps responding "ack continue" until it fills up its received-have buffer (currently 256 entries). Usually this is not a problem because the requester stops traversing the ancestry chain from the commit it gets "ack continue" for, but this mechanism does not work as a roadblock when it traverses down the path to the root the other side does not have. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
May 24, 2006 at 21:48 UTC
f061e5fdd6a65216976a8bd547b2340e6297217b
1 file changed
+16
fetch-pack.c
+16
@@ -18,6 +18,12 @@ static const char *exec = "git-upload-pack";
18
#define SEEN (1U << 3)
19
#define POPPED (1U << 4)
20
21
+/*
22
+ * After sending this many "have"s if we do not get any new ACK , we
23
+ * give up traversing our history.
24
+ */
25
+#define MAX_IN_VAIN 256
26
+
27
static struct commit_list *rev_list = NULL;
28
static int non_common_revs = 0, multi_ack = 0, use_thin_pack = 0;
29
@@ -134,6 +140,8 @@ static int find_common(int fd[2], unsigned char *result_sha1,
140
int fetching;
141
int count = 0, flushes = 0, retval;
142
const unsigned char *sha1;
143
+ unsigned in_vain = 0;
144
+ int got_continue = 0;
145
146
for_each_ref(rev_list_insert_ref);
147
@@ -172,6 +180,7 @@ static int find_common(int fd[2], unsigned char *result_sha1,
180
packet_write(fd[1], "have %s\n", sha1_to_hex(sha1));
181
if (verbose)
182
fprintf(stderr, "have %s\n", sha1_to_hex(sha1));
183
+ in_vain++;
184
if (!(31 & ++count)) {
185
int ack;
186
@@ -200,9 +209,16 @@ static int find_common(int fd[2], unsigned char *result_sha1,
209
lookup_commit(result_sha1);
210
mark_common(commit, 0, 1);
211
retval = 0;
212
+ in_vain = 0;
213
+ got_continue = 1;
214
}
215
} while (ack);
216
flushes--;
217
+ if (got_continue && MAX_IN_VAIN < in_vain) {
218
+ if (verbose)
219
+ fprintf(stderr, "giving up\n");
220
+ break; /* give up */
221
+ }
222
}
223
}
224
done: