Skip to content

Commit d1610ee

Browse files
avargitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9f3df6c commit d1610ee

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

run-command.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,10 +1565,11 @@ static void pp_init(struct parallel_processes *pp,
15651565
sigchain_push_common(handle_children_on_signal);
15661566
}
15671567

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)
15691570
{
15701571
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++) {
15721573
strbuf_release(&pp->children[i].err);
15731574
child_process_clear(&pp->children[i].process);
15741575
}
@@ -1647,19 +1648,21 @@ static int pp_start_one(struct parallel_processes *pp,
16471648
return 0;
16481649
}
16491650

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)
16511654
{
16521655
int i;
16531656

1654-
while ((i = poll(pp->pfd, pp->max_processes, output_timeout)) < 0) {
1657+
while ((i = poll(pp->pfd, opts->processes, output_timeout) < 0)) {
16551658
if (errno == EINTR)
16561659
continue;
1657-
pp_cleanup(pp);
1660+
pp_cleanup(pp, opts);
16581661
die_errno("poll");
16591662
}
16601663

16611664
/* 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++) {
16631666
if (pp->children[i].state == GIT_CP_WORKING &&
16641667
pp->pfd[i].revents & (POLLIN | POLLHUP)) {
16651668
int n = strbuf_read_once(&pp->children[i].err,
@@ -1790,7 +1793,7 @@ void run_processes_parallel(const struct run_process_parallel_opts *opts)
17901793
for (size_t i = 0; i < opts->processes; i++)
17911794
pp.children[i].state = GIT_CP_WAIT_CLEANUP;
17921795
} else {
1793-
pp_buffer_stderr(&pp, output_timeout);
1796+
pp_buffer_stderr(&pp, opts, output_timeout);
17941797
pp_output(&pp);
17951798
}
17961799
code = pp_collect_finished(&pp, opts);
@@ -1801,7 +1804,7 @@ void run_processes_parallel(const struct run_process_parallel_opts *opts)
18011804
}
18021805
}
18031806

1804-
pp_cleanup(&pp);
1807+
pp_cleanup(&pp, opts);
18051808

18061809
if (do_trace2)
18071810
trace2_region_leave(tr2_category, tr2_label, NULL);

0 commit comments

Comments
 (0)