mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-05 18:05:42 +02:00
Tolerate short reads from pread()
This commit is contained in:
@@ -430,9 +430,20 @@ void *run_sort(void *v) {
|
|||||||
std::string s;
|
std::string s;
|
||||||
s.resize(end - start);
|
s.resize(end - start);
|
||||||
|
|
||||||
if (pread(a->indexfd, (void *) s.c_str(), end - start, start) != end - start) {
|
const char *dest = s.c_str();
|
||||||
fprintf(stderr, "pread(index): %s\n", strerror(errno));
|
ssize_t off = start;
|
||||||
exit(EXIT_READ);
|
ssize_t count = end - start;
|
||||||
|
|
||||||
|
while (count > 0) {
|
||||||
|
ssize_t n = pread(a->indexfd, (void *) dest, count, off);
|
||||||
|
if (n < 0) {
|
||||||
|
fprintf(stderr, "pread(index): %s\n", strerror(errno));
|
||||||
|
exit(EXIT_READ);
|
||||||
|
}
|
||||||
|
|
||||||
|
dest += n;
|
||||||
|
off += n;
|
||||||
|
count -= n;
|
||||||
}
|
}
|
||||||
|
|
||||||
qsort((void *) s.c_str(), (end - start) / a->bytes, a->bytes, indexcmp);
|
qsort((void *) s.c_str(), (end - start) / a->bytes, a->bytes, indexcmp);
|
||||||
|
|||||||
Reference in New Issue
Block a user