mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-05 18:05:42 +02:00
Close input files that were being left open after parallel reading
This commit is contained in:
@@ -1198,6 +1198,16 @@ int read_input(std::vector<source> &sources, char *fname, int maxzoom, int minzo
|
|||||||
double dist_sum = 0;
|
double dist_sum = 0;
|
||||||
size_t dist_count = 0;
|
size_t dist_count = 0;
|
||||||
|
|
||||||
|
int files_open_before_reading = open("/dev/null", O_RDONLY | O_CLOEXEC);
|
||||||
|
if (files_open_before_reading < 0) {
|
||||||
|
perror("open /dev/null");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
if (close(files_open_before_reading) != 0) {
|
||||||
|
perror("close");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
size_t nsources = sources.size();
|
size_t nsources = sources.size();
|
||||||
for (size_t source = 0; source < nsources; source++) {
|
for (size_t source = 0; source < nsources; source++) {
|
||||||
std::string reading;
|
std::string reading;
|
||||||
@@ -1383,6 +1393,11 @@ int read_input(std::vector<source> &sources, char *fname, int maxzoom, int minzo
|
|||||||
perror("munmap source file");
|
perror("munmap source file");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (close(fd) != 0) {
|
||||||
|
perror("close input file");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
FILE *fp = fdopen(fd, "r");
|
FILE *fp = fdopen(fd, "r");
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
@@ -1543,6 +1558,22 @@ int read_input(std::vector<source> &sources, char *fname, int maxzoom, int minzo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int files_open_after_reading = open("/dev/null", O_RDONLY | O_CLOEXEC);
|
||||||
|
if (files_open_after_reading < 0) {
|
||||||
|
perror("open /dev/null");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
if (close(files_open_after_reading) != 0) {
|
||||||
|
perror("close");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (files_open_after_reading > files_open_before_reading) {
|
||||||
|
fprintf(stderr, "Internal error: Files left open after reading input. (%d vs %d)\n",
|
||||||
|
files_open_before_reading, files_open_after_reading);
|
||||||
|
ret = EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
if (!quiet) {
|
if (!quiet) {
|
||||||
fprintf(stderr, " \r");
|
fprintf(stderr, " \r");
|
||||||
// (stderr, "Read 10000.00 million features\r", *progress_seq / 1000000.0);
|
// (stderr, "Read 10000.00 million features\r", *progress_seq / 1000000.0);
|
||||||
|
|||||||
Reference in New Issue
Block a user