diff options
-rw-r--r-- | src/aof.c | 2 | ||||
-rw-r--r-- | src/cluster.c | 7 | ||||
-rw-r--r-- | src/config.c | 6 | ||||
-rw-r--r-- | src/rdb.c | 2 | ||||
-rw-r--r-- | src/redis.c | 38 | ||||
-rw-r--r-- | src/scripting.c | 2 |
6 files changed, 36 insertions, 21 deletions
@@ -1146,9 +1146,9 @@ int rewriteAppendOnlyFile(char *filename) { return REDIS_OK; werr: + redisLog(REDIS_WARNING,"Write error writing append only file on disk: %s", strerror(errno)); fclose(fp); unlink(tmpfile); - redisLog(REDIS_WARNING,"Write error writing append only file on disk: %s", strerror(errno)); if (di) dictReleaseIterator(di); return REDIS_ERR; } diff --git a/src/cluster.c b/src/cluster.c index fb45bd063..6280677ae 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -358,6 +358,11 @@ void clusterSaveConfigOrDie(int do_fsync) { * On success REDIS_OK is returned, otherwise an error is logged and * the function returns REDIS_ERR to signal a lock was not acquired. */ int clusterLockConfig(char *filename) { +/* flock() does not exist on Solaris + * and a fcntl-based solution won't help, as we constantly re-open that file, + * which will release _all_ locks anyway + */ +#if !defined(__sun) /* To lock it, we need to open the file in a way it is created if * it does not exist, otherwise there is a race condition with other * processes. */ @@ -385,6 +390,8 @@ int clusterLockConfig(char *filename) { } /* Lock acquired: leak the 'fd' by not closing it, so that we'll retain the * lock to the file as long as the process exists. */ +#endif /* __sun */ + return REDIS_OK; } diff --git a/src/config.c b/src/config.c index 6d51b1b08..fd56269ef 100644 --- a/src/config.c +++ b/src/config.c @@ -875,12 +875,12 @@ void configSetCommand(redisClient *c) { "activerehashing",server.activerehashing) { } config_set_bool_field( "stop-writes-on-bgsave-error",server.stop_writes_on_bgsave_err) { - } config_set_bool_field( - "tcp-keepalive",server.tcpkeepalive) { /* Numerical fields. * config_set_numerical_field(name,var,min,max) */ } config_set_numerical_field( + "tcp-keepalive",server.tcpkeepalive,0,LLONG_MAX) { + } config_set_numerical_field( "maxmemory-samples",server.maxmemory_samples,1,LLONG_MAX) { } config_set_numerical_field( "timeout",server.maxidletime,0,LONG_MAX) { @@ -1088,9 +1088,9 @@ void configGetCommand(redisClient *c) { config_get_numerical_field("cluster-migration-barrier",server.cluster_migration_barrier); config_get_numerical_field("cluster-slave-validity-factor",server.cluster_slave_validity_factor); config_get_numerical_field("repl-diskless-sync-delay",server.repl_diskless_sync_delay); + config_get_numerical_field("tcp-keepalive",server.tcpkeepalive); /* Bool (yes/no) values */ - config_get_bool_field("tcp-keepalive",server.tcpkeepalive); config_get_bool_field("cluster-require-full-coverage", server.cluster_require_full_coverage); config_get_bool_field("no-appendfsync-on-rewrite", @@ -869,9 +869,9 @@ int rdbSave(char *filename) { return REDIS_OK; werr: + redisLog(REDIS_WARNING,"Write error saving DB on disk: %s", strerror(errno)); fclose(fp); unlink(tmpfile); - redisLog(REDIS_WARNING,"Write error saving DB on disk: %s", strerror(errno)); return REDIS_ERR; } diff --git a/src/redis.c b/src/redis.c index 656c21ff2..b5ade925e 100644 --- a/src/redis.c +++ b/src/redis.c @@ -53,7 +53,6 @@ #include <sys/resource.h> #include <sys/utsname.h> #include <locale.h> -#include <sys/sysctl.h> #include <sys/socket.h> /* Our shared "common" objects */ @@ -290,7 +289,7 @@ struct redisCommand redisCommandTable[] = { {"geodist",geodistCommand,-4,"r",0,NULL,1,1,1,0,0}, {"pfselftest",pfselftestCommand,1,"r",0,NULL,0,0,0,0,0}, {"pfadd",pfaddCommand,-2,"wmF",0,NULL,1,1,1,0,0}, - {"pfcount",pfcountCommand,-2,"r",0,NULL,1,1,1,0,0}, + {"pfcount",pfcountCommand,-2,"r",0,NULL,1,-1,1,0,0}, {"pfmerge",pfmergeCommand,-2,"wm",0,NULL,1,-1,1,0,0}, {"pfdebug",pfdebugCommand,-3,"w",0,NULL,0,0,0,0,0}, {"latency",latencyCommand,-2,"arslt",0,NULL,0,0,0,0,0} @@ -912,9 +911,12 @@ long long getInstantaneousMetric(int metric) { return sum / REDIS_METRIC_SAMPLES; } -/* Check for timeouts. Returns non-zero if the client was terminated */ -int clientsCronHandleTimeout(redisClient *c) { - time_t now = server.unixtime; +/* Check for timeouts. Returns non-zero if the client was terminated. + * The function gets the current time in milliseconds as argument since + * it gets called multiple times in a loop, so calling gettimeofday() for + * each iteration would be costly without any actual gain. */ +int clientsCronHandleTimeout(redisClient *c, mstime_t now_ms) { + time_t now = now_ms/1000; if (server.maxidletime && !(c->flags & REDIS_SLAVE) && /* no timeout for slaves */ @@ -930,7 +932,6 @@ int clientsCronHandleTimeout(redisClient *c) { /* Blocked OPS timeout is handled with milliseconds resolution. * However note that the actual resolution is limited by * server.hz. */ - mstime_t now_ms = mstime(); if (c->bpop.timeout != 0 && c->bpop.timeout < now_ms) { /* Handle blocking operation specific timeout. */ @@ -972,17 +973,23 @@ int clientsCronResizeQueryBuffer(redisClient *c) { return 0; } +#define CLIENTS_CRON_MIN_ITERATIONS 5 void clientsCron(void) { - /* Make sure to process at least 1/(server.hz*10) of clients per call. - * Since this function is called server.hz times per second we are sure that - * in the worst case we process all the clients in 10 seconds. - * In normal conditions (a reasonable number of clients) we process - * all the clients in a shorter time. */ + /* Make sure to process at least numclients/server.hz of clients + * per call. Since this function is called server.hz times per second + * we are sure that in the worst case we process all the clients in 1 + * second. */ int numclients = listLength(server.clients); - int iterations = numclients/(server.hz*10); + int iterations = numclients/server.hz; + mstime_t now = mstime(); + + /* Process at least a few clients while we are at it, even if we need + * to process less than CLIENTS_CRON_MIN_ITERATIONS to meet our contract + * of processing each client once per second. */ + if (iterations < CLIENTS_CRON_MIN_ITERATIONS) + iterations = (numclients < CLIENTS_CRON_MIN_ITERATIONS) ? + numclients : CLIENTS_CRON_MIN_ITERATIONS; - if (iterations < 50) - iterations = (numclients < 50) ? numclients : 50; while(listLength(server.clients) && iterations--) { redisClient *c; listNode *head; @@ -996,7 +1003,7 @@ void clientsCron(void) { /* The following functions do different service checks on the client. * The protocol is that they return non-zero if the client was * terminated. */ - if (clientsCronHandleTimeout(c)) continue; + if (clientsCronHandleTimeout(c,now)) continue; if (clientsCronResizeQueryBuffer(c)) continue; } } @@ -1753,6 +1760,7 @@ void resetServerStats(void) { } server.stat_net_input_bytes = 0; server.stat_net_output_bytes = 0; + server.aof_delayed_fsync = 0; } void initServer(void) { diff --git a/src/scripting.c b/src/scripting.c index e8da69f74..228770bfa 100644 --- a/src/scripting.c +++ b/src/scripting.c @@ -876,7 +876,7 @@ void luaSetGlobalArray(lua_State *lua, char *var, robj **elev, int elec) { } /* Define a lua function with the specified function name and body. - * The function name musts be a 2 characters long string, since all the + * The function name musts be a 42 characters long string, since all the * functions we defined in the Lua context are in the form: * * f_<hex sha1 sum> |