port to macosx, add explicit dependency on mapkeeper
git-svn-id: svn+ssh://svn.corp.yahoo.com/yahoo/yrl/labs/pnuts/code/logstore@3508 8dad8b1f-cf64-0410-95b6-bcf113ffbcfe
This commit is contained in:
parent
bed774467a
commit
7bb6c3e166
2 changed files with 36 additions and 12 deletions
15
Makefile
15
Makefile
|
@ -1,15 +1,24 @@
|
|||
include ../mapkeeper/Makefile.config
|
||||
|
||||
INC = -I ../stasis \
|
||||
-I ../mapkeeper/thrift/gen-cpp/ \
|
||||
-I ../../local/thrift/include/ \
|
||||
-I ../../local/thrift/include/thrift \
|
||||
-I $(THRIFT_DIR)/include/ \
|
||||
-I $(THRIFT_DIR)/include/thrift \
|
||||
-I ./sherpa
|
||||
|
||||
LIBSRC = $(wildcard *.c) $(wildcard *.cpp)
|
||||
LIBNAME = logstore
|
||||
|
||||
ifeq (`uname`,"Linux")
|
||||
STATIC_LIBS= ./libstdc++.a ../mapkeeper/thrift/gen-cpp/libmapkeeper.a \
|
||||
-lrt sherpa/LSMServerHandler.cc bin/liblogstore.a \
|
||||
../stasis/bin/libstasis.a
|
||||
else
|
||||
STATIC_LIBS= ./libstdc++.a ../mapkeeper/thrift/gen-cpp/libmapkeeper.a \
|
||||
sherpa/LSMServerHandler.cc bin/liblogstore.a \
|
||||
../stasis/bin/libstasis.a
|
||||
endif
|
||||
|
||||
MAINSRC = $(wildcard main/*.cpp) $(wildcard sherpa/main/*.cc)
|
||||
|
||||
include ../stasis/config/Makefile.stasis
|
||||
include ../stasis/config/Makefile.stasis
|
||||
|
|
33
network.h
33
network.h
|
@ -69,13 +69,28 @@ typedef enum {
|
|||
LOGSTORE_SERVER_RESPONSE
|
||||
} logstore_opcode_type;
|
||||
|
||||
#ifndef MYFREAD
|
||||
#ifdef HAVE_FREAD_UNLOCKED
|
||||
#define MYFREAD(a,b,c,d) fread_unlocked(a,b,c,d)
|
||||
#define MYFWRITE(a,b,c,d) fwrite_unlocked(a,b,c,d)
|
||||
#define MYFEOF(a) feof_unlocked(a)
|
||||
#define MYFERROR(a) ferror_unlocked(a)
|
||||
#define MYFFLUSH(a) fflush_unlocked(a)
|
||||
#else
|
||||
#define MYFREAD(a,b,c,d) fread(a,b,c,d)
|
||||
#define MYFWRITE(a,b,c,d) fwrite(a,b,c,d)
|
||||
#define MYFEOF(a) feof(a)
|
||||
#define MYFERROR(a) ferror(a)
|
||||
#define MYFFLUSH(a) fflush(a)
|
||||
#endif
|
||||
#endif
|
||||
static inline int readfromsocket(FILE * sockf, void *buf, ssize_t count) {
|
||||
ssize_t i = fread_unlocked(buf, sizeof(byte), count, sockf);
|
||||
ssize_t i = MYFREAD(buf, sizeof(byte), count, sockf);
|
||||
if(i != count) {
|
||||
if(feof_unlocked(sockf)) {
|
||||
if(MYFEOF(sockf)) {
|
||||
errno = EOF;
|
||||
return EOF;
|
||||
} else if(ferror_unlocked(sockf)) {
|
||||
} else if(MYFERROR(sockf)) {
|
||||
perror("readfromsocket failed");
|
||||
errno = -1;
|
||||
return -1;
|
||||
|
@ -108,12 +123,12 @@ static inline int readfromsocket(int sockd, void *buf, ssize_t count)
|
|||
}
|
||||
|
||||
static inline int writetosocket(FILE * sockf, const void *buf, ssize_t count) {
|
||||
ssize_t i = fwrite_unlocked((byte*)buf, sizeof(byte), count, sockf);
|
||||
ssize_t i = MYFWRITE((byte*)buf, sizeof(byte), count, sockf);
|
||||
if(i != count) {
|
||||
if(feof_unlocked(sockf)) {
|
||||
if(MYFEOF(sockf)) {
|
||||
errno = EOF;
|
||||
return errno;
|
||||
} else if(ferror_unlocked(sockf)) {
|
||||
} else if(MYFERROR(sockf)) {
|
||||
perror("writetosocket failed");
|
||||
errno = -1;
|
||||
return -1;
|
||||
|
@ -155,8 +170,8 @@ static inline bool opisresponse(network_op_t op) {
|
|||
|
||||
static inline network_op_t readopfromsocket(FILE * sockf, logstore_opcode_type type) {
|
||||
network_op_t ret;
|
||||
fflush_unlocked(sockf); // our first read after a write is always (?) a readop, so fflush the write here.
|
||||
ssize_t n = fread_unlocked(&ret, sizeof(network_op_t), 1, sockf);
|
||||
MYFFLUSH(sockf); // our first read after a write is always (?) a readop, so fflush the write here.
|
||||
ssize_t n = MYFREAD(&ret, sizeof(network_op_t), 1, sockf);
|
||||
if(n == sizeof(network_op_t)) {
|
||||
// done.
|
||||
} else if(n == 0) { // EOF
|
||||
|
@ -232,7 +247,7 @@ static inline int writeoptosocket(FILE * sockf, network_op_t op) {
|
|||
assert(opiserror(op) || opisrequest(op) || opisresponse(op));
|
||||
int ret = writetosocket(sockf, &op, sizeof(network_op_t));
|
||||
if(op == LOGSTORE_RESPONSE_RECEIVING_TUPLES) {
|
||||
fflush_unlocked(sockf);
|
||||
MYFFLUSH(sockf);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue