run-command.c: pass "opts" further down, and use "opts->processes"
Continue the migration away from the "max_processes" member of "struct parallel_processes" to the "processes" member of the "struct run_process_parallel_opts", in this case we needed to pass the "opts" further down into pp_cleanup() and pp_buffer_stderr(). Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ævar Arnfjörð Bjarmason committed
Oct 12, 2022 at 23:02 UTC
d1610eef3f66d5735e087cde64bb4ab8cd5d9271
1 file changed
+11
-8
run-command.c
+11
-8
@@ -1565,10 +1565,11 @@ static void pp_init(struct parallel_processes *pp,
1565
sigchain_push_common(handle_children_on_signal);
1566
}
1567
1568
-static void pp_cleanup(struct parallel_processes *pp)
1568
+static void pp_cleanup(struct parallel_processes *pp,
1569
+ const struct run_process_parallel_opts *opts)
1570
{
1571
trace_printf("run_processes_parallel: done");
1571
- for (size_t i = 0; i < pp->max_processes; i++) {
1572
+ for (size_t i = 0; i < opts->processes; i++) {
1573
strbuf_release(&pp->children[i].err);
1574
child_process_clear(&pp->children[i].process);
1575
}
@@ -1647,19 +1648,21 @@ static int pp_start_one(struct parallel_processes *pp,
1648
return 0;
1649
}
1650
1650
-static void pp_buffer_stderr(struct parallel_processes *pp, int output_timeout)
1651
+static void pp_buffer_stderr(struct parallel_processes *pp,
1652
+ const struct run_process_parallel_opts *opts,
1653
+ int output_timeout)
1654
{
1655
int i;
1656
1654
- while ((i = poll(pp->pfd, pp->max_processes, output_timeout)) < 0) {
1657
+ while ((i = poll(pp->pfd, opts->processes, output_timeout) < 0)) {
1658
if (errno == EINTR)
1659
continue;
1657
- pp_cleanup(pp);
1660
+ pp_cleanup(pp, opts);
1661
die_errno("poll");
1662
}
1663
1664
/* Buffer output from all pipes. */
1662
- for (size_t i = 0; i < pp->max_processes; i++) {
1665
+ for (size_t i = 0; i < opts->processes; i++) {
1666
if (pp->children[i].state == GIT_CP_WORKING &&
1667
pp->pfd[i].revents & (POLLIN | POLLHUP)) {
1668
int n = strbuf_read_once(&pp->children[i].err,
@@ -1790,7 +1793,7 @@ void run_processes_parallel(const struct run_process_parallel_opts *opts)
1793
for (size_t i = 0; i < opts->processes; i++)
1794
pp.children[i].state = GIT_CP_WAIT_CLEANUP;
1795
} else {
1793
- pp_buffer_stderr(&pp, output_timeout);
1796
+ pp_buffer_stderr(&pp, opts, output_timeout);
1797
pp_output(&pp);
1798
}
1799
code = pp_collect_finished(&pp, opts);
@@ -1801,7 +1804,7 @@ void run_processes_parallel(const struct run_process_parallel_opts *opts)
1804
}
1805
}
1806
1804
- pp_cleanup(&pp);
1807
+ pp_cleanup(&pp, opts);
1808
1809
if (do_trace2)
1810
trace2_region_leave(tr2_category, tr2_label, NULL);