struct parallel_processes {
void *data;
- int max_processes;
- int nr_processes;
+ size_t max_processes;
+ size_t nr_processes;
get_next_task_fn get_next_task;
start_failure_fn start_failure;
unsigned shutdown : 1;
unsigned ungroup : 1;
- int output_owner;
+ size_t output_owner;
struct strbuf buffered_output; /* of finished children */
};
static void kill_children(struct parallel_processes *pp, int signo)
{
- int i, n = pp->max_processes;
-
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < pp->max_processes; i++)
if (pp->children[i].state == GIT_CP_WORKING)
kill(pp->children[i].process.pid, signo);
}
}
static void pp_init(struct parallel_processes *pp,
- int n,
+ size_t n,
get_next_task_fn get_next_task,
start_failure_fn start_failure,
task_finished_fn task_finished,
void *data, int ungroup)
{
- int i;
-
if (n < 1)
n = online_cpus();
pp->max_processes = n;
- trace_printf("run_processes_parallel: preparing to run up to %d tasks", n);
+ trace_printf("run_processes_parallel: preparing to run up to %"PRIuMAX" tasks",
+ (uintmax_t)n);
pp->data = data;
if (!get_next_task)
CALLOC_ARRAY(pp->pfd, n);
strbuf_init(&pp->buffered_output, 0);
- for (i = 0; i < n; i++) {
+ for (size_t i = 0; i < n; i++) {
strbuf_init(&pp->children[i].err, 0);
child_process_init(&pp->children[i].process);
if (pp->pfd) {
static void pp_cleanup(struct parallel_processes *pp)
{
- int i;
-
trace_printf("run_processes_parallel: done");
- for (i = 0; i < pp->max_processes; i++) {
+ for (size_t i = 0; i < pp->max_processes; i++) {
strbuf_release(&pp->children[i].err);
child_process_clear(&pp->children[i].process);
}
*/
static int pp_start_one(struct parallel_processes *pp)
{
- int i, code;
+ size_t i;
+ int code;
for (i = 0; i < pp->max_processes; i++)
if (pp->children[i].state == GIT_CP_FREE)
}
/* Buffer output from all pipes. */
- for (i = 0; i < pp->max_processes; i++) {
+ for (size_t i = 0; i < pp->max_processes; i++) {
if (pp->children[i].state == GIT_CP_WORKING &&
pp->pfd[i].revents & (POLLIN | POLLHUP)) {
int n = strbuf_read_once(&pp->children[i].err,
static void pp_output(struct parallel_processes *pp)
{
- int i = pp->output_owner;
+ size_t i = pp->output_owner;
if (pp->children[i].state == GIT_CP_WORKING &&
pp->children[i].err.len) {
static int pp_collect_finished(struct parallel_processes *pp)
{
- int i, code;
- int n = pp->max_processes;
+ int code;
+ size_t i, n = pp->max_processes;
int result = 0;
while (pp->nr_processes > 0) {
return result;
}
-void run_processes_parallel(int n,
+void run_processes_parallel(size_t n,
get_next_task_fn get_next_task,
start_failure_fn start_failure,
task_finished_fn task_finished,
if (!pp.nr_processes)
break;
if (ungroup) {
- int i;
-
- for (i = 0; i < pp.max_processes; i++)
+ for (size_t i = 0; i < pp.max_processes; i++)
pp.children[i].state = GIT_CP_WAIT_CLEANUP;
} else {
pp_buffer_stderr(&pp, output_timeout);
pp_cleanup(&pp);
}
-void run_processes_parallel_tr2(int n, get_next_task_fn get_next_task,
+void run_processes_parallel_tr2(size_t n, get_next_task_fn get_next_task,
start_failure_fn start_failure,
task_finished_fn task_finished, void *pp_cb,
const char *tr2_category, const char *tr2_label)