mirror of
https://github.com/fluencelabs/redis
synced 2025-05-15 12:01:21 +00:00
Store SELECTed database for reconnect (issue #468)
This commit is contained in:
parent
45332cc47b
commit
699465c31e
@ -264,11 +264,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;
|
||||||
@ -492,6 +490,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]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user