diff options
author | dormando <dormando@rydia.net> | 2020-04-10 19:21:28 -0700 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2020-04-10 19:21:28 -0700 |
commit | 543d206341dc58070be36bbda61f32ebd677fb8c (patch) | |
tree | bf8811e41acae94b96b27fb0f9762e2a223e652f /extstore.c | |
parent | 35b387aecbe75b49cb508981a511764badaffc89 (diff) | |
download | memcached-543d206341dc58070be36bbda61f32ebd677fb8c.tar.gz |
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 :(
Diffstat (limited to 'extstore.c')
-rw-r--r-- | extstore.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -16,6 +16,7 @@ #include <string.h> #include <assert.h> #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) { |