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
96e34b3c
Commit
96e34b3c
authored
Mar 06, 2011
by
Pieter Noordhuis
Browse files
Store SELECTed database for reconnect (issue #468)
parent
33753a73
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/redis-cli.c
View file @
96e34b3c
...
@@ -263,11 +263,9 @@ static int cliAuth() {
...
@@ -263,11 +263,9 @@ static int cliAuth() {
/* Send SELECT dbnum to the server */
/* Send SELECT dbnum to the server */
static
int
cliSelect
()
{
static
int
cliSelect
()
{
redisReply
*
reply
;
redisReply
*
reply
;
char
dbnum
[
16
];
if
(
config
.
dbnum
==
0
)
return
REDIS_OK
;
if
(
config
.
dbnum
==
0
)
return
REDIS_OK
;
snprintf
(
dbnum
,
sizeof
(
dbnum
),
"%d"
,
config
.
dbnum
);
reply
=
redisCommand
(
context
,
"SELECT %d"
,
config
.
dbnum
);
reply
=
redisCommand
(
context
,
"SELECT %s"
,
dbnum
);
if
(
reply
!=
NULL
)
{
if
(
reply
!=
NULL
)
{
freeReplyObject
(
reply
);
freeReplyObject
(
reply
);
return
REDIS_OK
;
return
REDIS_OK
;
...
@@ -491,6 +489,10 @@ static int cliSendCommand(int argc, char **argv, int repeat) {
...
@@ -491,6 +489,10 @@ static int cliSendCommand(int argc, char **argv, int repeat) {
if
(
cliReadReply
(
output_raw
)
!=
REDIS_OK
)
{
if
(
cliReadReply
(
output_raw
)
!=
REDIS_OK
)
{
free
(
argvlen
);
free
(
argvlen
);
return
REDIS_ERR
;
return
REDIS_ERR
;
}
else
{
/* Store database number when SELECT was successfully executed. */
if
(
!
strcasecmp
(
command
,
"select"
)
&&
argc
==
2
)
config
.
dbnum
=
atoi
(
argv
[
1
]);
}
}
}
}
...
...
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