提交 bbf0736c 编写于 作者: A antirez

sdsformatip() removed.

Specialized single-use function. Not the best match for sds.c btw.
Also genClientPeerId() is no longer static: we need symbols.
上级 ce269ad3
......@@ -1230,7 +1230,7 @@ void getClientsMaxBuffers(unsigned long *longest_output_list,
* On failure the function still populates 'peerid' with the "?:0" string
* in case you want to relax error checking or need to display something
* anyway (see anetPeerToString implementation for more info). */
static void genClientPeerId(redisClient *client, char *peerid,
void genClientPeerId(redisClient *client, char *peerid,
size_t peerid_len) {
if (client->flags & REDIS_UNIX_SOCKET) {
/* Unix socket client. */
......
......@@ -962,15 +962,6 @@ sds sdsjoin(char **argv, int argc, char *sep) {
return join;
}
sds sdsformatip(char *ip, int port) {
if (port >= 0)
return sdscatfmt(sdsempty(),
strchr(ip,':') ? "[%s]:%i" : "%s:%i", ip, port);
else
return sdscatfmt(sdsempty(),
strchr(ip,':') ? "[%s]" : "%s", ip);
}
#ifdef SDS_TEST_MAIN
#include <stdio.h>
#include "testhelp.h"
......
......@@ -91,7 +91,6 @@ sds sdscatrepr(sds s, const char *p, size_t len);
sds *sdssplitargs(const char *line, int *argc);
sds sdsmapchars(sds s, const char *from, const char *to, size_t setlen);
sds sdsjoin(char **argv, int argc, char *sep);
sds sdsformatip(char *ip, int port);
/* Low level functions exposed to the user API */
sds sdsMakeRoomFor(sds s, size_t addlen);
......
......@@ -1031,9 +1031,11 @@ sentinelRedisInstance *sentinelRedisInstanceLookupSlave(
{
sds key;
sentinelRedisInstance *slave;
char buf[REDIS_PEER_ID_LEN];
redisAssert(ri->flags & SRI_MASTER);
key = sdsformatip(ip, port);
anetFormatAddr(buf,sizeof(buf),ip,port);
key = sdsnew(buf);
slave = dictFetchValue(ri->slaves,key);
sdsfree(key);
return slave;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册