MCPcopy Index your code
hub / github.com/git/git / pp_collect_finished

Function pp_collect_finished

run-command.c:1809–1874  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1807}
1808
1809static int pp_collect_finished(struct parallel_processes *pp,
1810 const struct run_process_parallel_opts *opts)
1811{
1812 int code;
1813 size_t i;
1814 int result = 0;
1815
1816 while (pp->nr_processes > 0) {
1817 for (i = 0; i < opts->processes; i++)
1818 if (pp->children[i].state == GIT_CP_WAIT_CLEANUP)
1819 break;
1820 if (i == opts->processes)
1821 break;
1822
1823 code = finish_command(&pp->children[i].process);
1824
1825 if (opts->task_finished)
1826 code = opts->task_finished(code, opts->ungroup ? NULL :
1827 &pp->children[i].err, opts->data,
1828 pp->children[i].data);
1829 else
1830 code = 0;
1831
1832 if (code)
1833 result = code;
1834 if (code < 0)
1835 break;
1836
1837 pp->nr_processes--;
1838 pp->children[i].state = GIT_CP_FREE;
1839 if (pp->pfd)
1840 pp->pfd[i].fd = -1;
1841 pp->children[i].process.in = 0;
1842 child_process_init(&pp->children[i].process);
1843
1844 if (opts->ungroup) {
1845 ; /* no strbuf_*() work to do here */
1846 } else if (i != pp->output_owner) {
1847 strbuf_addbuf(&pp->buffered_output, &pp->children[i].err);
1848 strbuf_reset(&pp->children[i].err);
1849 } else {
1850 const size_t n = opts->processes;
1851
1852 strbuf_write(&pp->children[i].err, stderr);
1853 strbuf_reset(&pp->children[i].err);
1854
1855 /* Output all other finished child processes */
1856 strbuf_write(&pp->buffered_output, stderr);
1857 strbuf_reset(&pp->buffered_output);
1858
1859 /*
1860 * Pick next process to output live.
1861 * NEEDSWORK:
1862 * For now we pick it randomly by doing a round
1863 * robin. Later we may want to pick the one with
1864 * the most output or the longest or shortest
1865 * running process time.
1866 */

Callers 1

run_processes_parallelFunction · 0.85

Calls 5

finish_commandFunction · 0.85
child_process_initFunction · 0.85
strbuf_addbufFunction · 0.85
strbuf_writeFunction · 0.85
child_is_workingFunction · 0.85

Tested by

no test coverage detected