diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ae.c | 6 | ||||
-rw-r--r-- | src/config.h | 17 | ||||
-rw-r--r-- | src/endianconv.h | 1 | ||||
-rw-r--r-- | src/fmacros.h | 2 | ||||
-rw-r--r-- | src/networking.c | 4 | ||||
-rw-r--r-- | src/redis-benchmark.c | 2 | ||||
-rw-r--r-- | src/redis-cli.c | 2 | ||||
-rwxr-xr-x | src/redis.c | 5 | ||||
-rwxr-xr-x | src/replication.c | 4 | ||||
-rwxr-xr-x | src/scripting.c | 41 | ||||
-rw-r--r-- | src/version.h | 2 |
11 files changed, 55 insertions, 31 deletions
@@ -38,6 +38,7 @@ #include <poll.h> #include <string.h> #include <time.h> +#include <errno.h> #include "ae.h" #include "zmalloc.h" @@ -104,7 +105,10 @@ void aeStop(aeEventLoop *eventLoop) { int aeCreateFileEvent(aeEventLoop *eventLoop, int fd, int mask, aeFileProc *proc, void *clientData) { - if (fd >= eventLoop->setsize) return AE_ERR; + if (fd >= eventLoop->setsize) { + errno = ERANGE; + return AE_ERR; + } aeFileEvent *fe = &eventLoop->events[fd]; if (aeApiAddEvent(eventLoop, fd, mask) == -1) diff --git a/src/config.h b/src/config.h index db33407c5..b5c8284a0 100644 --- a/src/config.h +++ b/src/config.h @@ -137,13 +137,27 @@ #endif /* BSD */ #endif /* BYTE_ORDER */ -#if defined(__BYTE_ORDER) && !defined(BYTE_ORDER) +/* Sometimes after including an OS-specific header that defines the + * endianess we end with __BYTE_ORDER but not with BYTE_ORDER that is what + * the Redis code uses. In this case let's define everything without the + * underscores. */ +#ifndef BYTE_ORDER +#ifdef __BYTE_ORDER +#if defined(__LITTLE_ENDIAN) && defined(__BIG_ENDIAN) +#ifndef LITTLE_ENDIAN +#define LITTLE_ENDIAN __LITTLE_ENDIAN +#endif +#ifndef BIG_ENDIAN +#define BIG_ENDIAN __BIG_ENDIAN +#endif #if (__BYTE_ORDER == __LITTLE_ENDIAN) #define BYTE_ORDER LITTLE_ENDIAN #else #define BYTE_ORDER BIG_ENDIAN #endif #endif +#endif +#endif #if !defined(BYTE_ORDER) || \ (BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN) @@ -162,5 +176,4 @@ #endif #endif - #endif diff --git a/src/endianconv.h b/src/endianconv.h index f76e0e6b3..7afe61c62 100644 --- a/src/endianconv.h +++ b/src/endianconv.h @@ -33,6 +33,7 @@ #ifndef __ENDIANCONV_H #define __ENDIANCONV_H +#include "config.h" #include <stdint.h> void memrev16(void *p); diff --git a/src/fmacros.h b/src/fmacros.h index 6f3c4b4e8..a6cf3578c 100644 --- a/src/fmacros.h +++ b/src/fmacros.h @@ -36,7 +36,7 @@ #define _GNU_SOURCE #endif -#if defined(__linux__) || defined(__OpenBSD__) +#if defined(__linux__) || defined(__OpenBSD__) || defined(__NetBSD__) #define _XOPEN_SOURCE 700 #else #define _XOPEN_SOURCE diff --git a/src/networking.c b/src/networking.c index 4365bc8ef..c23939c5c 100644 --- a/src/networking.c +++ b/src/networking.c @@ -517,7 +517,9 @@ void copyClientOutputBuffer(redisClient *dst, redisClient *src) { static void acceptCommonHandler(int fd, int flags) { redisClient *c; if ((c = createClient(fd)) == NULL) { - redisLog(REDIS_WARNING,"Error allocating resources for the client"); + redisLog(REDIS_WARNING, + "Error registering fd event for the new client: %s (fd=%d)", + strerror(errno),fd); close(fd); /* May be already closed, just ignore errors */ return; } diff --git a/src/redis-benchmark.c b/src/redis-benchmark.c index 8d72573d5..ceab70723 100644 --- a/src/redis-benchmark.c +++ b/src/redis-benchmark.c @@ -106,7 +106,7 @@ static long long mstime(void) { long long mst; gettimeofday(&tv, NULL); - mst = ((long)tv.tv_sec)*1000; + mst = ((long long)tv.tv_sec)*1000; mst += tv.tv_usec/1000; return mst; } diff --git a/src/redis-cli.c b/src/redis-cli.c index e8c6be5e0..3969fbab5 100644 --- a/src/redis-cli.c +++ b/src/redis-cli.c @@ -95,7 +95,7 @@ static long long mstime(void) { long long mst; gettimeofday(&tv, NULL); - mst = ((long)tv.tv_sec)*1000; + mst = ((long long)tv.tv_sec)*1000; mst += tv.tv_usec/1000; return mst; } diff --git a/src/redis.c b/src/redis.c index e6731ba8b..04289db23 100755 --- a/src/redis.c +++ b/src/redis.c @@ -1655,8 +1655,9 @@ void call(redisClient *c, int flags) { if (flags != REDIS_PROPAGATE_NONE) propagate(c->cmd,c->db->id,c->argv,c->argc,flags); } - /* Commands such as LPUSH or BRPOPLPUSH may propagate an additional - * PUSH command. */ + + /* Handle the alsoPropagate() API to handle commands that want to propagate + * multiple separated commands. */ if (server.also_propagate.numops) { int j; redisOp *rop; diff --git a/src/replication.c b/src/replication.c index 9e2aed268..0a4321095 100755 --- a/src/replication.c +++ b/src/replication.c @@ -758,7 +758,9 @@ void syncWithMaster(aeEventLoop *el, int fd, void *privdata, int mask) { if (aeCreateFileEvent(server.el,fd, AE_READABLE,readSyncBulkPayload,NULL) == AE_ERR) { - redisLog(REDIS_WARNING,"Can't create readable event for SYNC"); + redisLog(REDIS_WARNING, + "Can't create readable event for SYNC: %s (fd=%d)", + strerror(errno),fd); goto error; } diff --git a/src/scripting.c b/src/scripting.c index b8d3f519c..e3f810815 100755 --- a/src/scripting.c +++ b/src/scripting.c @@ -791,7 +791,7 @@ void evalGenericCommand(redisClient *c, int evalsha) { lua_State *lua = server.lua; char funcname[43]; long long numkeys; - int delhook = 0; + int delhook = 0, err; /* We want the same PRNG sequence at every call so that our PRNG is * not affected by external state. */ @@ -873,30 +873,31 @@ void evalGenericCommand(redisClient *c, int evalsha) { /* At this point whatever this script was never seen before or if it was * already defined, we can call it. We have zero arguments and expect * a single return value. */ - if (lua_pcall(lua,0,1,0)) { - if (delhook) lua_sethook(lua,luaMaskCountHook,0,0); /* Disable hook */ - if (server.lua_timedout) { - server.lua_timedout = 0; - /* Restore the readable handler that was unregistered when the - * script timeout was detected. */ - aeCreateFileEvent(server.el,c->fd,AE_READABLE, - readQueryFromClient,c); - } - server.lua_caller = NULL; - selectDb(c,server.lua_client->db->id); /* set DB ID from Lua client */ - addReplyErrorFormat(c,"Error running script (call to %s): %s\n", - funcname, lua_tostring(lua,-1)); - lua_pop(lua,1); - lua_gc(lua,LUA_GCCOLLECT,0); - return; - } + err = lua_pcall(lua,0,1,0); + + /* Perform some cleanup that we need to do both on error and success. */ if (delhook) lua_sethook(lua,luaMaskCountHook,0,0); /* Disable hook */ - server.lua_timedout = 0; + if (server.lua_timedout) { + server.lua_timedout = 0; + /* Restore the readable handler that was unregistered when the + * script timeout was detected. */ + aeCreateFileEvent(server.el,c->fd,AE_READABLE, + readQueryFromClient,c); + } server.lua_caller = NULL; selectDb(c,server.lua_client->db->id); /* set DB ID from Lua client */ - luaReplyToRedisReply(c,lua); lua_gc(lua,LUA_GCSTEP,1); + if (err) { + addReplyErrorFormat(c,"Error running script (call to %s): %s\n", + funcname, lua_tostring(lua,-1)); + lua_pop(lua,1); /* Consume the Lua reply. */ + } else { + /* On success convert the Lua return value into Redis protocol, and + * send it to * the client. */ + luaReplyToRedisReply(c,lua); + } + /* If we have slaves attached we want to replicate this command as * EVAL instead of EVALSHA. We do this also in the AOF as currently there * is no easy way to propagate a command in a different way in the AOF diff --git a/src/version.h b/src/version.h index 32b61ccbc..c0881950f 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define REDIS_VERSION "2.6.7" +#define REDIS_VERSION "2.6.8" |