+ long port;
+
+ if ((getLongFromObjectOrReply(c, c->argv[2], &port, NULL) != REDIS_OK))
+ return;
+
+ /* Check if we are already attached to the specified slave */
+ if (server.masterhost && !strcasecmp(server.masterhost,c->argv[1]->ptr)
+ && server.masterport == port) {
+ redisLog(REDIS_NOTICE,"SLAVE OF would result into synchronization with the master we are already connected with. No operation performed.");
+ addReplySds(c,sdsnew("+OK Already connected to specified master\r\n"));
+ return;
+ }
+ /* There was no previous master or the user specified a different one,
+ * we can continue. */