From 543d206341dc58070be36bbda61f32ebd677fb8c Mon Sep 17 00:00:00 2001 From: dormando Date: Fri, 10 Apr 2020 19:21:28 -0700 Subject: fix extstore reads for OSX/cygwin pread[v]() is missing on some platforms. We had a test added to build under OS X, but the lseek arguments were swapped and tests would've never passed. I never force-tested the replacement code until checking this out for a cygwin build error :( --- extstore.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'extstore.c') diff --git a/extstore.c b/extstore.c index e825667..6ce9ba6 100644 --- a/extstore.c +++ b/extstore.c @@ -16,6 +16,7 @@ #include #include #include "extstore.h" +#include "config.h" // TODO: better if an init option turns this on/off. #ifdef EXTSTORE_DEBUG @@ -773,14 +774,20 @@ static void *extstore_io_thread(void *arg) { } pthread_mutex_unlock(&p->mutex); if (do_op) { -#ifdef __APPLE__ - ret = lseek(p->fd, SEEK_SET, p->offset + cur_io->offset); +#if !defined(HAVE_PREAD) || !defined(HAVE_PREADV) + // TODO: lseek offset is natively 64-bit on OS X, but + // perhaps not on all platforms? Else use lseek64() + ret = lseek(p->fd, p->offset + cur_io->offset, SEEK_SET); if (ret >= 0) { if (cur_io->iov == NULL) { ret = read(p->fd, cur_io->buf, cur_io->len); } else { ret = readv(p->fd, cur_io->iov, cur_io->iovcnt); } +#ifdef EXTSTORE_DEBUG + } else { + perror("lseek failed"); +#endif } #else if (cur_io->iov == NULL) { -- cgit v1.2.1