From 3cd534aefba5393589951e951bc421c130be4b38 Mon Sep 17 00:00:00 2001 From: siddontang Date: Sat, 14 Feb 2015 09:25:01 +0800 Subject: [PATCH] fix slave role err, ip and port must be master --- server/cmd_replication.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/cmd_replication.go b/server/cmd_replication.go index 7aa2e17..9bcba86 100644 --- a/server/cmd_replication.go +++ b/server/cmd_replication.go @@ -188,9 +188,11 @@ func roleCommand(c *client) error { } c.app.m.Lock() - isMaster := len(c.app.cfg.SlaveOf) == 0 + slaveof := c.app.cfg.SlaveOf c.app.m.Unlock() + isMaster := len(slaveof) == 0 + ay := make([]interface{}, 0, 5) var lastId int64 = 0 @@ -217,7 +219,7 @@ func roleCommand(c *client) error { c.app.slock.Unlock() ay = append(ay, items) } else { - host, port, _ := splitHostPort(c.app.cfg.Addr) + host, port, _ := splitHostPort(slaveof) ay = append(ay, []byte("slave")) ay = append(ay, []byte(host)) ay = append(ay, int64(port))