summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2011-06-17 16:13:22 +0200
committerantirez <antirez@gmail.com>2011-06-17 16:16:46 +0200
commit07486df6fecae97b02171bba86f51d5df0a94cb5 (patch)
tree52f4e84113c1a0fc23b9e8ea29613878d6fa85e3
parent591f29e0f5493f1e375c06ae225dc5aafe5b37fb (diff)
downloadredis-07486df6fecae97b02171bba86f51d5df0a94cb5.tar.gz
new INFO filed master_link_down_since_seconds
-rw-r--r--src/networking.c1
-rw-r--r--src/redis.c7
-rw-r--r--src/redis.h1
3 files changed, 9 insertions, 0 deletions
diff --git a/src/networking.c b/src/networking.c
index 4a6a8afd8..c7b56ca4c 100644
--- a/src/networking.c
+++ b/src/networking.c
@@ -522,6 +522,7 @@ void freeClient(redisClient *c) {
if (c->flags & REDIS_MASTER) {
server.master = NULL;
server.replstate = REDIS_REPL_CONNECT;
+ server.repl_down_since = time(NULL);
/* Since we lost the connection with the master, we should also
* close the connection with all our slaves if we have any, so
* when we'll resync with the master the other slaves will sync again
diff --git a/src/redis.c b/src/redis.c
index e7351b6ef..8fbed746d 100644
--- a/src/redis.c
+++ b/src/redis.c
@@ -901,6 +901,7 @@ void initServerConfig() {
server.replstate = REDIS_REPL_NONE;
server.repl_syncio_timeout = REDIS_REPL_SYNCIO_TIMEOUT;
server.repl_serve_stale_data = 1;
+ server.repl_down_since = -1;
/* Double constants initialization */
R_Zero = 0.0;
@@ -1522,6 +1523,12 @@ sds genRedisInfoString(char *section) {
(int)(time(NULL)-server.repl_transfer_lastio)
);
}
+
+ if (server.replstate != REDIS_REPL_CONNECTED) {
+ info = sdscatprintf(info,
+ "master_link_down_since_seconds:%ld\r\n",
+ (long)time(NULL)-server.repl_down_since);
+ }
}
info = sdscatprintf(info,
"connected_slaves:%d\r\n",
diff --git a/src/redis.h b/src/redis.h
index ce62d226b..3b5cb0230 100644
--- a/src/redis.h
+++ b/src/redis.h
@@ -604,6 +604,7 @@ struct redisServer {
char *repl_transfer_tmpfile; /* slave-> master SYNC temp file name */
time_t repl_transfer_lastio; /* unix time of the latest read, for timeout */
int repl_serve_stale_data; /* Serve stale data when link is down? */
+ time_t repl_down_since; /* unix time at which link with master went down */
/* Limits */
unsigned int maxclients;
unsigned long long maxmemory;