mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-02-02 01:08:14 +00:00
Don't let the input buffer for parallel streaming input get too big.
This commit is contained in:
parent
9d48d6a93d
commit
e846b11ce7
@ -1,3 +1,7 @@
|
||||
## 1.9.12
|
||||
|
||||
* Limit the size of the parallel parsing streaming input buffer
|
||||
|
||||
## 1.9.11
|
||||
|
||||
* Fix a line simplification crash when a segment degenerates to a single point
|
||||
|
23
geojson.c
23
geojson.c
@ -1711,6 +1711,8 @@ int read_json(int argc, struct source **sourcelist, char *fname, const char *lay
|
||||
|
||||
#define READ_BUF 2000
|
||||
#define PARSE_MIN 10000000
|
||||
#define PARSE_MAX (1LL * 1024 * 1024 * 1024)
|
||||
|
||||
char buf[READ_BUF];
|
||||
int n;
|
||||
|
||||
@ -1718,7 +1720,12 @@ int read_json(int argc, struct source **sourcelist, char *fname, const char *lay
|
||||
fwrite_check(buf, sizeof(char), n, readfp, reading);
|
||||
ahead += n;
|
||||
|
||||
if (buf[n - 1] == '\n' && ahead > PARSE_MIN && is_parsing == 0) {
|
||||
if (buf[n - 1] == '\n' && ahead > PARSE_MIN) {
|
||||
int already_waited = 0;
|
||||
|
||||
// Don't let the streaming reader get too far ahead of the parsers.
|
||||
// If the buffered input gets huge, block until the parsers are done.
|
||||
while (ahead >= PARSE_MAX && is_parsing != 0) {
|
||||
if (initial_offset != 0) {
|
||||
if (pthread_join(parallel_parser, NULL) != 0) {
|
||||
perror("pthread_join");
|
||||
@ -1726,6 +1733,19 @@ int read_json(int argc, struct source **sourcelist, char *fname, const char *lay
|
||||
}
|
||||
}
|
||||
|
||||
already_waited = 1;
|
||||
}
|
||||
|
||||
if (is_parsing == 0) {
|
||||
if (!already_waited) {
|
||||
if (initial_offset != 0) {
|
||||
if (pthread_join(parallel_parser, NULL) != 0) {
|
||||
perror("pthread_join");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fflush(readfp);
|
||||
start_parsing(readfd, readfp, initial_offset, ahead, &is_parsing, ¶llel_parser, reading, reader, &progress_seq, exclude, include, exclude_all, fname, basezoom, source, nlayers, droprate, initialized, initial_x, initial_y);
|
||||
|
||||
@ -1748,6 +1768,7 @@ int read_json(int argc, struct source **sourcelist, char *fname, const char *lay
|
||||
unlink(readname);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (n < 0) {
|
||||
perror(reading);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user