summaryrefslogtreecommitdiff
path: root/extstore.c
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2020-04-10 19:21:28 -0700
committerdormando <dormando@rydia.net>2020-04-10 19:21:28 -0700
commit543d206341dc58070be36bbda61f32ebd677fb8c (patch)
treebf8811e41acae94b96b27fb0f9762e2a223e652f /extstore.c
parent35b387aecbe75b49cb508981a511764badaffc89 (diff)
downloadmemcached-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.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/extstore.c b/extstore.c
index e825667..6ce9ba6 100644
--- a/extstore.c
+++ b/extstore.c
@@ -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) {