Skip to content

Commit 06b3d38

Browse files
jonathantanmygitster
authored andcommitted
fetch-pack: do not reset in_vain on non-novel acks
The MAX_IN_VAIN mechanism was introduced in commit f061e5f ("fetch-pack: give up after getting too many "ack continue"", 2006-05-24) to stop ref negotiation if a number of consecutive "have"s have been sent with no corresponding new acks. This is to stop the client from digging too deep in an irrelevant side branch in vain without ever finding a common ancestor. A use case (as described in that commit) is the scenario in which the local repository has more roots than the remote repository. However, during a negotiation in which stateless RPCs are used, MAX_IN_VAIN will (almost) never trigger (in the more-roots scenario above and others) because in each new request, the client has to inform the server of objects it already has and knows the server has (to remind the server of the state), which the server then acks. Make fetch-pack only consider, as new acks for the purpose of MAX_IN_VAIN, acks for objects for which the client has never received an ack before in this session. Signed-off-by: Jonathan Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7c0304a commit 06b3d38

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

fetch-pack.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,10 +428,17 @@ static int find_common(struct fetch_pack_args *args,
428428
const char *hex = sha1_to_hex(result_sha1);
429429
packet_buf_write(&req_buf, "have %s\n", hex);
430430
state_len = req_buf.len;
431-
}
431+
/*
432+
* Reset in_vain because an ack
433+
* for this commit has not been
434+
* seen.
435+
*/
436+
in_vain = 0;
437+
} else if (!args->stateless_rpc
438+
|| ack != ACK_common)
439+
in_vain = 0;
432440
mark_common(commit, 0, 1);
433441
retval = 0;
434-
in_vain = 0;
435442
got_continue = 1;
436443
if (ack == ACK_ready) {
437444
clear_prio_queue(&rev_list);

0 commit comments

Comments
 (0)