summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2014-04-28 16:41:38 +0200
committerantirez <antirez@gmail.com>2014-04-28 18:17:02 +0200
commitbb00154f0ede555ec546d3e705693a61305de2e0 (patch)
tree225fdcdceb41842af7448ee6846d2c1592c070ae
parente285a57073041dff22254c1f7f688c73abd0928f (diff)
downloadredis-bb00154f0ede555ec546d3e705693a61305de2e0.tar.gz
Use sdscatfmt() in getClientInfoString() to make it faster.
-rw-r--r--src/networking.c18
-rw-r--r--src/sds.h1
2 files changed, 10 insertions, 9 deletions
diff --git a/src/networking.c b/src/networking.c
index 46e8cafdc..6e4687f22 100644
--- a/src/networking.c
+++ b/src/networking.c
@@ -1285,23 +1285,23 @@ sds getClientInfoString(redisClient *client) {
if (emask & AE_READABLE) *p++ = 'r';
if (emask & AE_WRITABLE) *p++ = 'w';
*p = '\0';
- return sdscatprintf(sdsempty(),
- "addr=%s fd=%d name=%s age=%ld idle=%ld flags=%s db=%d sub=%d psub=%d multi=%d qbuf=%lu qbuf-free=%lu obl=%lu oll=%lu omem=%lu events=%s cmd=%s",
+ return sdscatfmt(sdsempty(),
+ "addr=%s fd=%i name=%s age=%I idle=%I flags=%s db=%i sub=%i psub=%i multi=%i qbuf=%U qbuf-free=%U obl=%U oll=%U omem=%U events=%s cmd=%s",
peerid,
client->fd,
client->name ? (char*)client->name->ptr : "",
- (long)(server.unixtime - client->ctime),
- (long)(server.unixtime - client->lastinteraction),
+ (long long)(server.unixtime - client->ctime),
+ (long long)(server.unixtime - client->lastinteraction),
flags,
client->db->id,
(int) dictSize(client->pubsub_channels),
(int) listLength(client->pubsub_patterns),
(client->flags & REDIS_MULTI) ? client->mstate.count : -1,
- (unsigned long) sdslen(client->querybuf),
- (unsigned long) sdsavail(client->querybuf),
- (unsigned long) client->bufpos,
- (unsigned long) listLength(client->reply),
- getClientOutputBufferMemoryUsage(client),
+ (unsigned long long) sdslen(client->querybuf),
+ (unsigned long long) sdsavail(client->querybuf),
+ (unsigned long long) client->bufpos,
+ (unsigned long long) listLength(client->reply),
+ (unsigned long long) getClientOutputBufferMemoryUsage(client),
events,
client->lastcmd ? client->lastcmd->name : "NULL");
}
diff --git a/src/sds.h b/src/sds.h
index 615c751cd..9a604021c 100644
--- a/src/sds.h
+++ b/src/sds.h
@@ -76,6 +76,7 @@ sds sdscatprintf(sds s, const char *fmt, ...)
sds sdscatprintf(sds s, const char *fmt, ...);
#endif
+sds sdscatfmt(sds s, char const *fmt, ...);
sds sdstrim(sds s, const char *cset);
void sdsrange(sds s, int start, int end);
void sdsupdatelen(sds s);