diff options
-rw-r--r-- | .travis.yml | 15 | ||||
-rw-r--r-- | adapters/libuv.h | 5 | ||||
-rw-r--r-- | fmacros.h | 2 | ||||
-rw-r--r-- | hiredis.h | 2 | ||||
-rw-r--r-- | net.c | 1 | ||||
-rw-r--r-- | sds.c | 2 | ||||
-rw-r--r-- | sds.h | 2 |
7 files changed, 24 insertions, 5 deletions
diff --git a/.travis.yml b/.travis.yml index 1e1ce30..ad08076 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,13 @@ compiler: - gcc - clang +os: + - linux + - osx + +before_script: + - if [ "$TRAVIS_OS_NAME" == "osx" ] ; then brew update; brew install redis; fi + addons: apt: packages: @@ -21,4 +28,12 @@ env: - TARGET="32bit" TARGET_VARS="32bit-vars" CFLAGS="-Werror" - TARGET="32bit" TARGET_VARS="32bit-vars" PRE="valgrind --track-origins=yes --leak-check=full" +matrix: + exclude: + - os: osx + env: PRE="valgrind --track-origins=yes --leak-check=full" + + - os: osx + env: TARGET="32bit" TARGET_VARS="32bit-vars" PRE="valgrind --track-origins=yes --leak-check=full" + script: make $TARGET CFLAGS="$CFLAGS" && make check PRE="$PRE" && make $TARGET_VARS hiredis-example diff --git a/adapters/libuv.h b/adapters/libuv.h index 3cdf3d3..ff08c25 100644 --- a/adapters/libuv.h +++ b/adapters/libuv.h @@ -20,10 +20,10 @@ static void redisLibuvPoll(uv_poll_t* handle, int status, int events) { return; } - if (events & UV_READABLE) { + if (p->context != NULL && (events & UV_READABLE)) { redisAsyncHandleRead(p->context); } - if (events & UV_WRITABLE) { + if (p->context != NULL && (events & UV_WRITABLE)) { redisAsyncHandleWrite(p->context); } } @@ -83,6 +83,7 @@ static void on_close(uv_handle_t* handle) { static void redisLibuvCleanup(void *privdata) { redisLibuvEvents* p = (redisLibuvEvents*)privdata; + p->context = NULL; // indicate that context might no longer exist uv_close((uv_handle_t*)&p->handle, on_close); } @@ -13,8 +13,10 @@ #if defined(__sun__) #define _POSIX_C_SOURCE 200112L #else +#if !(defined(__APPLE__) && defined(__MACH__)) #define _XOPEN_SOURCE 600 #endif +#endif #if defined(__APPLE__) && defined(__MACH__) #define _OSX @@ -133,7 +133,7 @@ void redisFreeSdsCommand(sds cmd); enum redisConnectionType { REDIS_CONN_TCP, - REDIS_CONN_UNIX, + REDIS_CONN_UNIX }; /* Context for a connection to Redis */ @@ -384,6 +384,7 @@ addrretry: if (++reuses >= REDIS_CONNECT_RETRIES) { goto error; } else { + redisContextCloseFd(c); goto addrretry; } } else { @@ -89,9 +89,9 @@ sds sdsnewlen(const void *init, size_t initlen) { unsigned char *fp; /* flags pointer. */ sh = s_malloc(hdrlen+initlen+1); + if (sh == NULL) return NULL; if (!init) memset(sh, 0, hdrlen+initlen+1); - if (sh == NULL) return NULL; s = (char*)sh+hdrlen; fp = ((unsigned char*)s)-1; switch(type) { @@ -79,7 +79,7 @@ struct __attribute__ ((__packed__)) sdshdr64 { #define SDS_TYPE_64 4 #define SDS_TYPE_MASK 7 #define SDS_TYPE_BITS 3 -#define SDS_HDR_VAR(T,s) struct sdshdr##T *sh = (void*)((s)-(sizeof(struct sdshdr##T))); +#define SDS_HDR_VAR(T,s) struct sdshdr##T *sh = (struct sdshdr##T *)((s)-(sizeof(struct sdshdr##T))); #define SDS_HDR(T,s) ((struct sdshdr##T *)((s)-(sizeof(struct sdshdr##T)))) #define SDS_TYPE_5_LEN(f) ((f)>>SDS_TYPE_BITS) |