diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-17 14:29:29 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-20 03:18:47 +0200 |
commit | 9d7d0a84a2017af2e70cc0f33bfbce0b59470e62 (patch) | |
tree | f06ddabcebc1210d3764ada396284b46cebedc8d /unpack/fill_files.c | |
parent | 544f8f6dfd2f61fd1d2ab7a9a955e63d4b416dcc (diff) |
Remove parallel unpacking
Parallel unpacking didn't really improve the speed that much. Actually
sorting the files for optimized unpack order improved speed much more
than the parallel unpacker.
Furthermore, the fork based parallel unpacker was actually pretty messy
to begin with.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'unpack/fill_files.c')
-rw-r--r-- | unpack/fill_files.c | 62 |
1 files changed, 7 insertions, 55 deletions
diff --git a/unpack/fill_files.c b/unpack/fill_files.c index c0fc26c..df6ca7e 100644 --- a/unpack/fill_files.c +++ b/unpack/fill_files.c @@ -38,65 +38,17 @@ static int fill_files(data_reader_t *data, file_info_t *list, int flags) return 0; } -int fill_unpacked_files(fstree_t *fs, data_reader_t *data, int flags, - unsigned int num_jobs) +int fill_unpacked_files(fstree_t *fs, data_reader_t *data, int flags) { - file_info_t **sublists, *it; - int exitstatus, status = 0; - unsigned int i; - pid_t pid; + file_info_t *list, *it; + int status = 0; - if (num_jobs < 1) - num_jobs = 1; + list = optimize_unpack_order(fs); - sublists = alloca(sizeof(sublists[0]) * num_jobs); - optimize_unpack_order(fs, num_jobs, sublists); + status = fill_files(data, list, flags); - if (num_jobs < 2) { - status = fill_files(data, sublists[0], flags); - goto out; - } - - for (i = 0; i < num_jobs; ++i) { - pid = fork(); - - if (pid == 0) { - /* Kill the child when the parent process dies */ - prctl(PR_SET_PDEATHSIG, SIGKILL); - - if (fill_files(data, sublists[i], flags)) - exit(EXIT_FAILURE); - exit(EXIT_SUCCESS); - } - - if (pid < 0) { - perror("fork"); - status = -1; - break; - } - } - - for (;;) { - errno = 0; - pid = waitpid(-1, &exitstatus, 0); - - if (pid < 0) { - if (errno == EINTR) - continue; - if (errno == ECHILD) - break; - } - - if (!WIFEXITED(exitstatus) || - WEXITSTATUS(exitstatus) != EXIT_SUCCESS) { - status = -1; - } - } -out: - for (i = 0; i < num_jobs; ++i) { - for (it = sublists[i]; it != NULL; it = it->next) - free(it->input_file); - } + for (it = list; it != NULL; it = it->next) + free(it->input_file); return status; } |