sdsformatip() removed.

Specialized single-use function. Not the best match for sds.c btw.
Also genClientPeerId() is no longer static: we need symbols.
This commit is contained in:
antirez 2014-12-11 18:28:26 +01:00
parent ce269ad3c5
commit bbf0736c4e
4 changed files with 4 additions and 12 deletions

View File

@ -1230,7 +1230,7 @@ void getClientsMaxBuffers(unsigned long *longest_output_list,
* On failure the function still populates 'peerid' with the "?:0" string * On failure the function still populates 'peerid' with the "?:0" string
* in case you want to relax error checking or need to display something * in case you want to relax error checking or need to display something
* anyway (see anetPeerToString implementation for more info). */ * anyway (see anetPeerToString implementation for more info). */
static void genClientPeerId(redisClient *client, char *peerid, void genClientPeerId(redisClient *client, char *peerid,
size_t peerid_len) { size_t peerid_len) {
if (client->flags & REDIS_UNIX_SOCKET) { if (client->flags & REDIS_UNIX_SOCKET) {
/* Unix socket client. */ /* Unix socket client. */

View File

@ -962,15 +962,6 @@ sds sdsjoin(char **argv, int argc, char *sep) {
return join; 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 #ifdef SDS_TEST_MAIN
#include <stdio.h> #include <stdio.h>
#include "testhelp.h" #include "testhelp.h"

View File

@ -91,7 +91,6 @@ sds sdscatrepr(sds s, const char *p, size_t len);
sds *sdssplitargs(const char *line, int *argc); sds *sdssplitargs(const char *line, int *argc);
sds sdsmapchars(sds s, const char *from, const char *to, size_t setlen); sds sdsmapchars(sds s, const char *from, const char *to, size_t setlen);
sds sdsjoin(char **argv, int argc, char *sep); sds sdsjoin(char **argv, int argc, char *sep);
sds sdsformatip(char *ip, int port);
/* Low level functions exposed to the user API */ /* Low level functions exposed to the user API */
sds sdsMakeRoomFor(sds s, size_t addlen); sds sdsMakeRoomFor(sds s, size_t addlen);

View File

@ -1031,9 +1031,11 @@ sentinelRedisInstance *sentinelRedisInstanceLookupSlave(
{ {
sds key; sds key;
sentinelRedisInstance *slave; sentinelRedisInstance *slave;
char buf[REDIS_PEER_ID_LEN];
redisAssert(ri->flags & SRI_MASTER); redisAssert(ri->flags & SRI_MASTER);
key = sdsformatip(ip, port); anetFormatAddr(buf,sizeof(buf),ip,port);
key = sdsnew(buf);
slave = dictFetchValue(ri->slaves,key); slave = dictFetchValue(ri->slaves,key);
sdsfree(key); sdsfree(key);
return slave; return slave;