323
{
324
int fetching;
325
int count = 0, flushes = 0, flush_at = INITIAL_FLUSH, retval;
326
+ int negotiation_round = 0, haves = 0;
327
const struct object_id *oid;
328
unsigned in_vain = 0;
329
int got_continue = 0;
462
packet_buf_write(&req_buf, "have %s\n", oid_to_hex(oid));
463
print_verbose(args, "have %s", oid_to_hex(oid));
464
in_vain++;
465
+ haves++;
466
if (flush_at <= ++count) {
467
int ack;
468
469
+ negotiation_round++;
470
+ trace2_region_enter_printf("negotiation_v0_v1", "round",
471
+ the_repository, "%d",
472
+ negotiation_round);
473
+ trace2_data_intmax("negotiation_v0_v1", the_repository,
474
+ "haves_added", haves);
475
+ trace2_data_intmax("negotiation_v0_v1", the_repository,
476
+ "in_vain", in_vain);
477
+ haves = 0;
478
packet_buf_flush(&req_buf);
479
send_request(args, fd[1], &req_buf);
480
strbuf_setlen(&req_buf, state_len);
496
ack, oid_to_hex(result_oid));
497
switch (ack) {
498
case ACK:
499
+ trace2_region_leave_printf("negotiation_v0_v1", "round",
500
+ the_repository, "%d",
501
+ negotiation_round);
502
flushes = 0;
503
multi_ack = 0;
504
retval = 0;
524
const char *hex = oid_to_hex(result_oid);
525
packet_buf_write(&req_buf, "have %s\n", hex);
526
state_len = req_buf.len;
527
+ haves++;
528
/*
529
* Reset in_vain because an ack
530
* for this commit has not been
543
}
544
} while (ack);
545
flushes--;
546
+ trace2_region_leave_printf("negotiation_v0_v1", "round",
547
+ the_repository, "%d",
548
+ negotiation_round);
549
if (got_continue && MAX_IN_VAIN < in_vain) {
550
print_verbose(args, _("giving up"));
551
break; /* give up */
556
}
557
done:
558
trace2_region_leave("fetch-pack", "negotiation_v0_v1", the_repository);
559
+ trace2_data_intmax("negotiation_v0_v1", the_repository, "total_rounds",
560
+ negotiation_round);
561
if (!got_ready || !no_done) {
562
packet_buf_write(&req_buf, "done\n");
563
send_request(args, fd[1], &req_buf);
1401
1402
haves_added = add_haves(negotiator, &req_buf, haves_to_send);
1403
*in_vain += haves_added;
1404
+ trace2_data_intmax("negotiation_v2", the_repository, "haves_added", haves_added);
1405
+ trace2_data_intmax("negotiation_v2", the_repository, "in_vain", *in_vain);
1406
if (!haves_added || (seen_ack && *in_vain >= MAX_IN_VAIN)) {
1407
/* Send Done */
1408
packet_buf_write(&req_buf, "done\n");
1645
struct oidset common = OIDSET_INIT;
1646
struct packet_reader reader;
1647
int in_vain = 0, negotiation_started = 0;
1648
+ int negotiation_round = 0;
1649
int haves_to_send = INITIAL_FLUSH;
1650
struct fetch_negotiator negotiator_alloc;
1651
struct fetch_negotiator *negotiator;
1702
"negotiation_v2",
1703
the_repository);
1704
}
1705
+ negotiation_round++;
1706
+ trace2_region_enter_printf("negotiation_v2", "round",
1707
+ the_repository, "%d",
1708
+ negotiation_round);
1709
if (send_fetch_request(negotiator, fd[1], args, ref,
1710
&common,
1711
&haves_to_send, &in_vain,
1712
reader.use_sideband,
1686
- seen_ack))
1713
+ seen_ack)) {
1714
+ trace2_region_leave_printf("negotiation_v2", "round",
1715
+ the_repository, "%d",
1716
+ negotiation_round);
1717
state = FETCH_GET_PACK;
1718
+ }
1719
else
1720
state = FETCH_PROCESS_ACKS;
1721
break;
1728
seen_ack = 1;
1729
oidset_insert(&common, &common_oid);
1730
}
1731
+ trace2_region_leave_printf("negotiation_v2", "round",
1732
+ the_repository, "%d",
1733
+ negotiation_round);
1734
if (received_ready) {
1735
/*
1736
* Don't check for response delimiter; get_pack() will
1746
trace2_region_leave("fetch-pack",
1747
"negotiation_v2",
1748
the_repository);
1749
+ trace2_data_intmax("negotiation_v2", the_repository,
1750
+ "total_rounds", negotiation_round);
1751
/* Check for shallow-info section */
1752
if (process_section_header(&reader, "shallow-info", 1))
1753
receive_shallow_info(args, &reader, shallows, si);
2127
int in_vain = 0;
2128
int seen_ack = 0;
2129
int last_iteration = 0;
2130
+ int negotiation_round = 0;
2131
timestamp_t min_generation = GENERATION_NUMBER_INFINITY;
2132
2133
fetch_negotiator_init(the_repository, &negotiator);
2141
add_to_object_array,
2142
&nt_object_array);
2143
2144
+ trace2_region_enter("fetch-pack", "negotiate_using_fetch", the_repository);
2145
while (!last_iteration) {
2146
int haves_added;
2147
struct object_id common_oid;
2148
int received_ready = 0;
2149
2150
+ negotiation_round++;
2151
+
2152
+ trace2_region_enter_printf("negotiate_using_fetch", "round",
2153
+ the_repository, "%d",
2154
+ negotiation_round);
2155
strbuf_reset(&req_buf);
2156
write_fetch_command_and_capabilities(&req_buf, server_options);
2157
2162
if (!haves_added || (seen_ack && in_vain >= MAX_IN_VAIN))
2163
last_iteration = 1;
2164
2165
+ trace2_data_intmax("negotiate_using_fetch", the_repository,
2166
+ "haves_added", haves_added);
2167
+ trace2_data_intmax("negotiate_using_fetch", the_repository,
2168
+ "in_vain", in_vain);
2169
+
2170
/* Send request */
2171
packet_buf_flush(&req_buf);
2172
if (write_in_full(fd[1], req_buf.buf, req_buf.len) < 0)
2199
REACH_SCRATCH, 0,
2200
min_generation))
2201
last_iteration = 1;
2202
+ trace2_region_leave_printf("negotiation", "round",
2203
+ the_repository, "%d",
2204
+ negotiation_round);
2205
}
2206
+ trace2_region_enter("fetch-pack", "negotiate_using_fetch", the_repository);
2207
+ trace2_data_intmax("negotiate_using_fetch", the_repository,
2208
+ "total_rounds", negotiation_round);
2209
clear_common_flag(acked_commits);
2210
strbuf_release(&req_buf);
2211
}