Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
b93fdb7b
Commit
b93fdb7b
authored
Apr 21, 2011
by
antirez
Browse files
CLIENT KILL implemented
parent
3cd12b56
Changes
1
Show whitespace changes
Inline
Side-by-side
src/networking.c
View file @
b93fdb7b
...
...
@@ -870,15 +870,16 @@ void getClientsMaxBuffers(unsigned long *longest_output_list,
}
void
clientCommand
(
redisClient
*
c
)
{
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"list"
)
&&
c
->
argc
==
2
)
{
listNode
*
ln
;
listIter
li
;
redisClient
*
client
;
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"list"
)
&&
c
->
argc
==
2
)
{
sds
o
=
sdsempty
();
time_t
now
=
time
(
NULL
);
listRewind
(
server
.
clients
,
&
li
);
while
((
ln
=
listNext
(
&
li
))
!=
NULL
)
{
redisClient
*
client
;
char
ip
[
32
],
flags
[
16
],
*
p
;
int
port
;
...
...
@@ -911,6 +912,26 @@ void clientCommand(redisClient *c) {
}
addReplyBulkCBuffer
(
c
,
o
,
sdslen
(
o
));
sdsfree
(
o
);
}
else
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"kill"
)
&&
c
->
argc
==
3
)
{
listRewind
(
server
.
clients
,
&
li
);
while
((
ln
=
listNext
(
&
li
))
!=
NULL
)
{
char
ip
[
32
],
addr
[
64
];
int
port
;
client
=
listNodeValue
(
ln
);
if
(
anetPeerToString
(
client
->
fd
,
ip
,
&
port
)
==
-
1
)
continue
;
snprintf
(
addr
,
sizeof
(
addr
),
"%s:%d"
,
ip
,
port
);
if
(
strcmp
(
addr
,
c
->
argv
[
2
]
->
ptr
)
==
0
)
{
addReply
(
c
,
shared
.
ok
);
if
(
c
==
client
)
{
client
->
flags
|=
REDIS_CLOSE_AFTER_REPLY
;
}
else
{
freeClient
(
client
);
}
return
;
}
}
addReplyError
(
c
,
"No such client"
);
}
else
{
addReplyError
(
c
,
"Syntax error, try CLIENT (LIST | KILL ip:port)"
);
}
...
...
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