From 76e772f39a971e14e9c8cd077b68ad8ed8cc7f97 Mon Sep 17 00:00:00 2001 From: antirez Date: Tue, 18 Oct 2011 11:09:32 +0200 Subject: [PATCH] Return from syncWithMaster() ASAP if the event fired but the instance is no longer a slave. This should fix Issue #145. --- src/replication.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/replication.c b/src/replication.c index 8090a27a5..13a1927a5 100644 --- a/src/replication.c +++ b/src/replication.c @@ -376,6 +376,13 @@ void syncWithMaster(aeEventLoop *el, int fd, void *privdata, int mask) { REDIS_NOTUSED(privdata); REDIS_NOTUSED(mask); + /* If this event fired after the user turned the instance into a master + * with SLAVEOF NO ONE we must just return ASAP. */ + if (server.replstate == REDIS_REPL_NONE) { + close(fd); + return; + } + redisLog(REDIS_NOTICE,"Non blocking connect for SYNC fired the event."); /* This event should only be triggered once since it is used to have a * non-blocking connect(2) to the master. It has been triggered when this -- GitLab