| 2243 | } |
| 2244 | |
| 2245 | void negotiate_using_fetch(const struct oid_array *negotiation_restrict_tips, |
| 2246 | const struct string_list *server_options, |
| 2247 | int stateless_rpc, |
| 2248 | int fd[], |
| 2249 | struct oidset *acked_commits, |
| 2250 | const struct oid_array *negotiation_include_tips) |
| 2251 | { |
| 2252 | struct fetch_negotiator negotiator; |
| 2253 | struct packet_reader reader; |
| 2254 | struct object_array nt_object_array = OBJECT_ARRAY_INIT; |
| 2255 | struct strbuf req_buf = STRBUF_INIT; |
| 2256 | struct oidset negotiation_include_oids = OIDSET_INIT; |
| 2257 | int haves_to_send = INITIAL_FLUSH; |
| 2258 | int in_vain = 0; |
| 2259 | int seen_ack = 0; |
| 2260 | int last_iteration = 0; |
| 2261 | int negotiation_round = 0; |
| 2262 | timestamp_t min_generation = GENERATION_NUMBER_INFINITY; |
| 2263 | |
| 2264 | fetch_negotiator_init(the_repository, &negotiator); |
| 2265 | mark_tips(&negotiator, negotiation_restrict_tips); |
| 2266 | |
| 2267 | add_oids_to_set(negotiation_include_tips, |
| 2268 | &negotiation_include_oids); |
| 2269 | |
| 2270 | packet_reader_init(&reader, fd[0], NULL, 0, |
| 2271 | PACKET_READ_CHOMP_NEWLINE | |
| 2272 | PACKET_READ_DIE_ON_ERR_PACKET); |
| 2273 | |
| 2274 | oid_array_for_each((struct oid_array *) negotiation_restrict_tips, |
| 2275 | add_to_object_array, |
| 2276 | &nt_object_array); |
| 2277 | |
| 2278 | trace2_region_enter("fetch-pack", "negotiate_using_fetch", the_repository); |
| 2279 | while (!last_iteration) { |
| 2280 | int haves_added; |
| 2281 | struct object_id common_oid; |
| 2282 | int received_ready = 0; |
| 2283 | |
| 2284 | negotiation_round++; |
| 2285 | |
| 2286 | trace2_region_enter_printf("negotiate_using_fetch", "round", |
| 2287 | the_repository, "%d", |
| 2288 | negotiation_round); |
| 2289 | strbuf_reset(&req_buf); |
| 2290 | write_fetch_command_and_capabilities(&req_buf, server_options); |
| 2291 | |
| 2292 | packet_buf_write(&req_buf, "wait-for-done"); |
| 2293 | |
| 2294 | haves_added = add_haves(&negotiator, &req_buf, &haves_to_send, |
| 2295 | &negotiation_include_oids); |
| 2296 | in_vain += haves_added; |
| 2297 | if (!haves_added || (seen_ack && in_vain >= MAX_IN_VAIN)) |
| 2298 | last_iteration = 1; |
| 2299 | |
| 2300 | trace2_data_intmax("negotiate_using_fetch", the_repository, |
| 2301 | "haves_added", haves_added); |
| 2302 | trace2_data_intmax("negotiate_using_fetch", the_repository, |
no test coverage detected