mirror of
https://github.com/fluencelabs/redis
synced 2025-06-16 02:31:20 +00:00
Merge branch 'unstable' into pending-querybuf
This commit is contained in:
46
src/server.c
46
src/server.c
@ -198,8 +198,8 @@ struct redisCommand redisCommandTable[] = {
|
||||
{"zrank",zrankCommand,3,"rF",0,NULL,1,1,1,0,0},
|
||||
{"zrevrank",zrevrankCommand,3,"rF",0,NULL,1,1,1,0,0},
|
||||
{"zscan",zscanCommand,-3,"rR",0,NULL,1,1,1,0,0},
|
||||
{"zpopmin",zpopminCommand,-2,"wF",0,NULL,1,-1,1,0,0},
|
||||
{"zpopmax",zpopmaxCommand,-2,"wF",0,NULL,1,-1,1,0,0},
|
||||
{"zpopmin",zpopminCommand,-2,"wF",0,NULL,1,1,1,0,0},
|
||||
{"zpopmax",zpopmaxCommand,-2,"wF",0,NULL,1,1,1,0,0},
|
||||
{"bzpopmin",bzpopminCommand,-2,"wsF",0,NULL,1,-2,1,0,0},
|
||||
{"bzpopmax",bzpopmaxCommand,-2,"wsF",0,NULL,1,-2,1,0,0},
|
||||
{"hset",hsetCommand,-4,"wmF",0,NULL,1,1,1,0,0},
|
||||
@ -845,13 +845,14 @@ int clientsCronResizeQueryBuffer(client *c) {
|
||||
|
||||
/* There are two conditions to resize the query buffer:
|
||||
* 1) Query buffer is > BIG_ARG and too big for latest peak.
|
||||
* 2) Client is inactive and the buffer is bigger than 1k. */
|
||||
if (((querybuf_size > PROTO_MBULK_BIG_ARG) &&
|
||||
(querybuf_size/(c->querybuf_peak+1)) > 2) ||
|
||||
(querybuf_size > 1024 && idletime > 2))
|
||||
* 2) Query buffer is > BIG_ARG and client is idle. */
|
||||
if (querybuf_size > PROTO_MBULK_BIG_ARG &&
|
||||
((querybuf_size/(c->querybuf_peak+1)) > 2 ||
|
||||
idletime > 2))
|
||||
{
|
||||
/* Only resize the query buffer if it is actually wasting space. */
|
||||
if (sdsavail(c->querybuf) > 1024) {
|
||||
/* Only resize the query buffer if it is actually wasting
|
||||
* at least a few kbytes. */
|
||||
if (sdsavail(c->querybuf) > 1024*4) {
|
||||
c->querybuf = sdsRemoveFreeSpace(c->querybuf);
|
||||
}
|
||||
}
|
||||
@ -1467,6 +1468,7 @@ void initServerConfig(void) {
|
||||
server.aof_selected_db = -1; /* Make sure the first time will not match */
|
||||
server.aof_flush_postponed_start = 0;
|
||||
server.aof_rewrite_incremental_fsync = CONFIG_DEFAULT_AOF_REWRITE_INCREMENTAL_FSYNC;
|
||||
server.rdb_save_incremental_fsync = CONFIG_DEFAULT_RDB_SAVE_INCREMENTAL_FSYNC;
|
||||
server.aof_load_truncated = CONFIG_DEFAULT_AOF_LOAD_TRUNCATED;
|
||||
server.aof_use_rdb_preamble = CONFIG_DEFAULT_AOF_USE_RDB_PREAMBLE;
|
||||
server.pidfile = NULL;
|
||||
@ -1496,6 +1498,8 @@ void initServerConfig(void) {
|
||||
server.zset_max_ziplist_entries = OBJ_ZSET_MAX_ZIPLIST_ENTRIES;
|
||||
server.zset_max_ziplist_value = OBJ_ZSET_MAX_ZIPLIST_VALUE;
|
||||
server.hll_sparse_max_bytes = CONFIG_DEFAULT_HLL_SPARSE_MAX_BYTES;
|
||||
server.stream_node_max_bytes = OBJ_STREAM_NODE_MAX_BYTES;
|
||||
server.stream_node_max_entries = OBJ_STREAM_NODE_MAX_ENTRIES;
|
||||
server.shutdown_asap = 0;
|
||||
server.cluster_enabled = 0;
|
||||
server.cluster_node_timeout = CLUSTER_DEFAULT_NODE_TIMEOUT;
|
||||
@ -1897,6 +1901,7 @@ void initServer(void) {
|
||||
server.pid = getpid();
|
||||
server.current_client = NULL;
|
||||
server.clients = listCreate();
|
||||
server.clients_index = raxNew();
|
||||
server.clients_to_close = listCreate();
|
||||
server.slaves = listCreate();
|
||||
server.monitors = listCreate();
|
||||
@ -2646,7 +2651,7 @@ int prepareForShutdown(int flags) {
|
||||
/* Append only file: flush buffers and fsync() the AOF at exit */
|
||||
serverLog(LL_NOTICE,"Calling fsync() on the AOF file.");
|
||||
flushAppendOnlyFile(1);
|
||||
aof_fsync(server.aof_fd);
|
||||
redis_fsync(server.aof_fd);
|
||||
}
|
||||
|
||||
/* Create a new RDB file before exiting. */
|
||||
@ -2835,9 +2840,9 @@ void commandCommand(client *c) {
|
||||
if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"help")) {
|
||||
const char *help[] = {
|
||||
"(no subcommand) -- Return details about all Redis commands.",
|
||||
"count -- Return the total number of commands in this Redis server.",
|
||||
"getkeys <full-command> -- Return the keys from a full Redis command.",
|
||||
"info [command-name ...] -- Return details about multiple Redis commands.",
|
||||
"COUNT -- Return the total number of commands in this Redis server.",
|
||||
"GETKEYS <full-command> -- Return the keys from a full Redis command.",
|
||||
"INFO [command-name ...] -- Return details about multiple Redis commands.",
|
||||
NULL
|
||||
};
|
||||
addReplyHelp(c, help);
|
||||
@ -2861,7 +2866,10 @@ NULL
|
||||
int *keys, numkeys, j;
|
||||
|
||||
if (!cmd) {
|
||||
addReplyErrorFormat(c,"Invalid command specified");
|
||||
addReplyError(c,"Invalid command specified");
|
||||
return;
|
||||
} else if (cmd->getkeys_proc == NULL && cmd->firstkey == 0) {
|
||||
addReplyError(c,"The command has no key arguments");
|
||||
return;
|
||||
} else if ((cmd->arity > 0 && cmd->arity != c->argc-2) ||
|
||||
((c->argc-2) < -cmd->arity))
|
||||
@ -2871,11 +2879,15 @@ NULL
|
||||
}
|
||||
|
||||
keys = getKeysFromCommand(cmd,c->argv+2,c->argc-2,&numkeys);
|
||||
addReplyMultiBulkLen(c,numkeys);
|
||||
for (j = 0; j < numkeys; j++) addReplyBulk(c,c->argv[keys[j]+2]);
|
||||
getKeysFreeResult(keys);
|
||||
if (!keys) {
|
||||
addReplyError(c,"Invalid arguments specified for command");
|
||||
} else {
|
||||
addReplyMultiBulkLen(c,numkeys);
|
||||
for (j = 0; j < numkeys; j++) addReplyBulk(c,c->argv[keys[j]+2]);
|
||||
getKeysFreeResult(keys);
|
||||
}
|
||||
} else {
|
||||
addReplyErrorFormat(c, "Unknown subcommand or wrong number of arguments for '%s'. Try COMMAND HELP", (char*)c->argv[1]->ptr);
|
||||
addReplySubcommandSyntaxError(c);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user