dst->reply_bytes = src->reply_bytes;
}
-static void acceptCommonHandler(int fd) {
+static void acceptCommonHandler(int fd, int flags) {
redisClient *c;
if ((c = createClient(fd)) == NULL) {
redisLog(REDIS_WARNING,"Error allocating resoures for the client");
return;
}
server.stat_numconnections++;
+ c->flags |= flags;
}
void acceptTcpHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
return;
}
redisLog(REDIS_VERBOSE,"Accepted %s:%d", cip, cport);
- acceptCommonHandler(cfd);
+ acceptCommonHandler(cfd,0);
}
void acceptUnixHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
return;
}
redisLog(REDIS_VERBOSE,"Accepted connection to %s", server.unixsocket);
- acceptCommonHandler(cfd);
+ acceptCommonHandler(cfd,REDIS_UNIX_SOCKET);
}
/* Turn a Redis client into an sds string representing its state. */
sds getClientInfoString(redisClient *client) {
char ip[32], flags[16], events[3], *p;
- int port;
+ int port = 0; /* initialized to zero for the unix socket case. */
int emask;
- anetPeerToString(client->fd,ip,&port);
+ if (!(client->flags & REDIS_UNIX_SOCKET))
+ anetPeerToString(client->fd,ip,&port);
p = flags;
if (client->flags & REDIS_SLAVE) {
if (client->flags & REDIS_MONITOR)
if (client->flags & REDIS_CLOSE_AFTER_REPLY) *p++ = 'c';
if (client->flags & REDIS_UNBLOCKED) *p++ = 'u';
if (client->flags & REDIS_CLOSE_ASAP) *p++ = 'A';
+ if (client->flags & REDIS_UNIX_SOCKET) *p++ = 'U';
if (p == flags) *p++ = 'N';
*p++ = '\0';
*p = '\0';
return sdscatprintf(sdsempty(),
"addr=%s:%d fd=%d 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",
- ip,port,client->fd,
+ (client->flags & REDIS_UNIX_SOCKET) ? server.unixsocket : ip,
+ port,client->fd,
(long)(server.unixtime - client->ctime),
(long)(server.unixtime - client->lastinteraction),
flags,
gettimeofday(&tv,NULL);
cmdrepr = sdscatprintf(cmdrepr,"%ld.%06ld ",(long)tv.tv_sec,(long)tv.tv_usec);
if (c->flags & REDIS_LUA_CLIENT) {
- cmdrepr = sdscatprintf(cmdrepr,"[%d lua] ", dictid);
+ cmdrepr = sdscatprintf(cmdrepr,"[%d lua] ",dictid);
+ } else if (c->flags & REDIS_UNIX_SOCKET) {
+ cmdrepr = sdscatprintf(cmdrepr,"[%d unix:%s] ",dictid,server.unixsocket);
} else {
anetPeerToString(c->fd,ip,&port);
- cmdrepr = sdscatprintf(cmdrepr,"[%d %s:%d] ", dictid,ip,port);
+ cmdrepr = sdscatprintf(cmdrepr,"[%d %s:%d] ",dictid,ip,port);
}
for (j = 0; j < argc; j++) {