X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/1237d71c4e4a9c617d0c8ce8049e16326e647cfe..989a7820ca0cb1b88493797fdecd2e7168558859:/src/redis.c diff --git a/src/redis.c b/src/redis.c index 1dcca1fd..82dade15 100644 --- a/src/redis.c +++ b/src/redis.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2010, Salvatore Sanfilippo + * Copyright (c) 2009-2012, Salvatore Sanfilippo * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -561,6 +561,16 @@ dictType clusterNodesDictType = { NULL /* val destructor */ }; +/* Migrate cache dict type. */ +dictType migrateCacheDictType = { + dictSdsHash, /* hash function */ + NULL, /* key dup */ + NULL, /* val dup */ + dictSdsKeyCompare, /* key compare */ + dictSdsDestructor, /* key destructor */ + NULL /* val destructor */ +}; + int htNeedsResize(dict *dict) { long long size, used; @@ -972,16 +982,21 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) { * to detect transfer failures. */ run_with_period(1000) replicationCron(); - /* Run other sub-systems specific cron jobs */ + /* Run the Redis Cluster cron. */ run_with_period(1000) { if (server.cluster_enabled) clusterCron(); } - /* Run the sentinel timer if we are in sentinel mode. */ + /* Run the Sentinel timer if we are in sentinel mode. */ run_with_period(100) { if (server.sentinel_mode) sentinelTimer(); } + /* Cleanup expired MIGRATE cached sockets. */ + run_with_period(1000) { + migrateCloseTimedoutSockets(); + } + server.cronloops++; return 1000/REDIS_HZ; } @@ -1149,6 +1164,7 @@ void initServerConfig() { server.lua_time_limit = REDIS_LUA_TIME_LIMIT; server.lua_client = NULL; server.lua_timedout = 0; + server.migrate_cached_sockets = dictCreate(&migrateCacheDictType,NULL); updateLRUClock(); resetServerSaveParams(); @@ -2066,7 +2082,8 @@ sds genRedisInfoString(char *section) { "keyspace_misses:%lld\r\n" "pubsub_channels:%ld\r\n" "pubsub_patterns:%lu\r\n" - "latest_fork_usec:%lld\r\n", + "latest_fork_usec:%lld\r\n" + "migrate_cached_sockets:%ld\r\n", server.stat_numconnections, server.stat_numcommands, getOperationsPerSecond(), @@ -2077,7 +2094,8 @@ sds genRedisInfoString(char *section) { server.stat_keyspace_misses, dictSize(server.pubsub_channels), listLength(server.pubsub_patterns), - server.stat_fork_time); + server.stat_fork_time, + dictSize(server.migrate_cached_sockets)); } /* Replication */