Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
2ea41242
Commit
2ea41242
authored
Nov 01, 2012
by
antirez
Browse files
Unix socket clients properly displayed in MONITOR and CLIENT LIST.
This also fixes issue #745.
parent
d36fb95a
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/networking.c
View file @
2ea41242
...
@@ -486,7 +486,7 @@ void copyClientOutputBuffer(redisClient *dst, redisClient *src) {
...
@@ -486,7 +486,7 @@ void copyClientOutputBuffer(redisClient *dst, redisClient *src) {
dst
->
reply_bytes
=
src
->
reply_bytes
;
dst
->
reply_bytes
=
src
->
reply_bytes
;
}
}
static
void
acceptCommonHandler
(
int
fd
)
{
static
void
acceptCommonHandler
(
int
fd
,
int
flags
)
{
redisClient
*
c
;
redisClient
*
c
;
if
((
c
=
createClient
(
fd
))
==
NULL
)
{
if
((
c
=
createClient
(
fd
))
==
NULL
)
{
redisLog
(
REDIS_WARNING
,
"Error allocating resoures for the client"
);
redisLog
(
REDIS_WARNING
,
"Error allocating resoures for the client"
);
...
@@ -509,6 +509,7 @@ static void acceptCommonHandler(int fd) {
...
@@ -509,6 +509,7 @@ static void acceptCommonHandler(int fd) {
return
;
return
;
}
}
server
.
stat_numconnections
++
;
server
.
stat_numconnections
++
;
c
->
flags
|=
flags
;
}
}
void
acceptTcpHandler
(
aeEventLoop
*
el
,
int
fd
,
void
*
privdata
,
int
mask
)
{
void
acceptTcpHandler
(
aeEventLoop
*
el
,
int
fd
,
void
*
privdata
,
int
mask
)
{
...
@@ -524,7 +525,7 @@ void acceptTcpHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
...
@@ -524,7 +525,7 @@ void acceptTcpHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
return
;
return
;
}
}
redisLog
(
REDIS_VERBOSE
,
"Accepted %s:%d"
,
cip
,
cport
);
redisLog
(
REDIS_VERBOSE
,
"Accepted %s:%d"
,
cip
,
cport
);
acceptCommonHandler
(
cfd
);
acceptCommonHandler
(
cfd
,
0
);
}
}
void
acceptUnixHandler
(
aeEventLoop
*
el
,
int
fd
,
void
*
privdata
,
int
mask
)
{
void
acceptUnixHandler
(
aeEventLoop
*
el
,
int
fd
,
void
*
privdata
,
int
mask
)
{
...
@@ -539,7 +540,7 @@ void acceptUnixHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
...
@@ -539,7 +540,7 @@ void acceptUnixHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
return
;
return
;
}
}
redisLog
(
REDIS_VERBOSE
,
"Accepted connection to %s"
,
server
.
unixsocket
);
redisLog
(
REDIS_VERBOSE
,
"Accepted connection to %s"
,
server
.
unixsocket
);
acceptCommonHandler
(
cfd
);
acceptCommonHandler
(
cfd
,
REDIS_UNIX_SOCKET
);
}
}
...
@@ -1062,10 +1063,11 @@ void getClientsMaxBuffers(unsigned long *longest_output_list,
...
@@ -1062,10 +1063,11 @@ void getClientsMaxBuffers(unsigned long *longest_output_list,
/* Turn a Redis client into an sds string representing its state. */
/* Turn a Redis client into an sds string representing its state. */
sds
getClientInfoString
(
redisClient
*
client
)
{
sds
getClientInfoString
(
redisClient
*
client
)
{
char
ip
[
32
],
flags
[
16
],
events
[
3
],
*
p
;
char
ip
[
32
],
flags
[
16
],
events
[
3
],
*
p
;
int
port
;
int
port
=
0
;
/* initialized to zero for the unix socket case. */
int
emask
;
int
emask
;
anetPeerToString
(
client
->
fd
,
ip
,
&
port
);
if
(
!
(
client
->
flags
&
REDIS_UNIX_SOCKET
))
anetPeerToString
(
client
->
fd
,
ip
,
&
port
);
p
=
flags
;
p
=
flags
;
if
(
client
->
flags
&
REDIS_SLAVE
)
{
if
(
client
->
flags
&
REDIS_SLAVE
)
{
if
(
client
->
flags
&
REDIS_MONITOR
)
if
(
client
->
flags
&
REDIS_MONITOR
)
...
@@ -1080,6 +1082,7 @@ sds getClientInfoString(redisClient *client) {
...
@@ -1080,6 +1082,7 @@ sds getClientInfoString(redisClient *client) {
if
(
client
->
flags
&
REDIS_CLOSE_AFTER_REPLY
)
*
p
++
=
'c'
;
if
(
client
->
flags
&
REDIS_CLOSE_AFTER_REPLY
)
*
p
++
=
'c'
;
if
(
client
->
flags
&
REDIS_UNBLOCKED
)
*
p
++
=
'u'
;
if
(
client
->
flags
&
REDIS_UNBLOCKED
)
*
p
++
=
'u'
;
if
(
client
->
flags
&
REDIS_CLOSE_ASAP
)
*
p
++
=
'A'
;
if
(
client
->
flags
&
REDIS_CLOSE_ASAP
)
*
p
++
=
'A'
;
if
(
client
->
flags
&
REDIS_UNIX_SOCKET
)
*
p
++
=
'U'
;
if
(
p
==
flags
)
*
p
++
=
'N'
;
if
(
p
==
flags
)
*
p
++
=
'N'
;
*
p
++
=
'\0'
;
*
p
++
=
'\0'
;
...
@@ -1090,7 +1093,8 @@ sds getClientInfoString(redisClient *client) {
...
@@ -1090,7 +1093,8 @@ sds getClientInfoString(redisClient *client) {
*
p
=
'\0'
;
*
p
=
'\0'
;
return
sdscatprintf
(
sdsempty
(),
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"
,
"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
->
ctime
),
(
long
)(
server
.
unixtime
-
client
->
lastinteraction
),
(
long
)(
server
.
unixtime
-
client
->
lastinteraction
),
flags
,
flags
,
...
...
src/redis.h
View file @
2ea41242
...
@@ -152,6 +152,7 @@
...
@@ -152,6 +152,7 @@
#define REDIS_LUA_CLIENT 512
/* This is a non connected client used by Lua */
#define REDIS_LUA_CLIENT 512
/* This is a non connected client used by Lua */
#define REDIS_ASKING 1024
/* Client issued the ASKING command */
#define REDIS_ASKING 1024
/* Client issued the ASKING command */
#define REDIS_CLOSE_ASAP 2048
/* Close this client ASAP */
#define REDIS_CLOSE_ASAP 2048
/* Close this client ASAP */
#define REDIS_UNIX_SOCKET 4096
/* Client connected via Unix domain socket */
/* Client request types */
/* Client request types */
#define REDIS_REQ_INLINE 1
#define REDIS_REQ_INLINE 1
...
...
src/replication.c
View file @
2ea41242
...
@@ -54,10 +54,12 @@ void replicationFeedMonitors(redisClient *c, list *monitors, int dictid, robj **
...
@@ -54,10 +54,12 @@ void replicationFeedMonitors(redisClient *c, list *monitors, int dictid, robj **
gettimeofday
(
&
tv
,
NULL
);
gettimeofday
(
&
tv
,
NULL
);
cmdrepr
=
sdscatprintf
(
cmdrepr
,
"%ld.%06ld "
,(
long
)
tv
.
tv_sec
,(
long
)
tv
.
tv_usec
);
cmdrepr
=
sdscatprintf
(
cmdrepr
,
"%ld.%06ld "
,(
long
)
tv
.
tv_sec
,(
long
)
tv
.
tv_usec
);
if
(
c
->
flags
&
REDIS_LUA_CLIENT
)
{
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
{
}
else
{
anetPeerToString
(
c
->
fd
,
ip
,
&
port
);
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
++
)
{
for
(
j
=
0
;
j
<
argc
;
j
++
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment