Commit f3efd529 authored by antirez's avatar antirez
Browse files

COMMANDS command: remove static + aesthetic changes.

Static was removed since it is needed in order to get symbols in stack
traces. Minor changes in the source code were operated to make it more
similar to the existing Redis code base.
parent fdc5dbd5
...@@ -2267,15 +2267,15 @@ void timeCommand(redisClient *c) { ...@@ -2267,15 +2267,15 @@ void timeCommand(redisClient *c) {
} }
static int replyCmdFlag(redisClient *c, int addReplyCommandFlag(redisClient *c, struct redisCommand *cmd, int f, char *reply) {
struct redisCommand *cmd, int f, char *reply) {
if (cmd->flags & f) { if (cmd->flags & f) {
addReplyStatus(c, reply); addReplyStatus(c, reply);
return 1; return 1;
} }
return 0; return 0;
} }
static void replyCmd(redisClient *c, struct redisCommand *cmd) {
void addReplyCommand(redisClient *c, struct redisCommand *cmd) {
if (!cmd) { if (!cmd) {
addReply(c, shared.nullbulk); addReply(c, shared.nullbulk);
} else { } else {
...@@ -2286,18 +2286,18 @@ static void replyCmd(redisClient *c, struct redisCommand *cmd) { ...@@ -2286,18 +2286,18 @@ static void replyCmd(redisClient *c, struct redisCommand *cmd) {
int flagcount = 0; int flagcount = 0;
void *flaglen = addDeferredMultiBulkLength(c); void *flaglen = addDeferredMultiBulkLength(c);
flagcount += replyCmdFlag(c,cmd,REDIS_CMD_WRITE, "write"); flagcount += addReplyCommandFlag(c,cmd,REDIS_CMD_WRITE, "write");
flagcount += replyCmdFlag(c,cmd,REDIS_CMD_READONLY, "readonly"); flagcount += addReplyCommandFlag(c,cmd,REDIS_CMD_READONLY, "readonly");
flagcount += replyCmdFlag(c,cmd,REDIS_CMD_DENYOOM, "denyoom"); flagcount += addReplyCommandFlag(c,cmd,REDIS_CMD_DENYOOM, "denyoom");
flagcount += replyCmdFlag(c,cmd,REDIS_CMD_ADMIN, "admin"); flagcount += addReplyCommandFlag(c,cmd,REDIS_CMD_ADMIN, "admin");
flagcount += replyCmdFlag(c,cmd,REDIS_CMD_PUBSUB, "pubsub"); flagcount += addReplyCommandFlag(c,cmd,REDIS_CMD_PUBSUB, "pubsub");
flagcount += replyCmdFlag(c,cmd,REDIS_CMD_NOSCRIPT, "noscript"); flagcount += addReplyCommandFlag(c,cmd,REDIS_CMD_NOSCRIPT, "noscript");
flagcount += replyCmdFlag(c,cmd,REDIS_CMD_RANDOM, "random"); flagcount += addReplyCommandFlag(c,cmd,REDIS_CMD_RANDOM, "random");
flagcount += replyCmdFlag(c,cmd,REDIS_CMD_SORT_FOR_SCRIPT,"scriptsort"); flagcount += addReplyCommandFlag(c,cmd,REDIS_CMD_SORT_FOR_SCRIPT,"sort_for_script");
flagcount += replyCmdFlag(c,cmd,REDIS_CMD_LOADING, "loading"); flagcount += addReplyCommandFlag(c,cmd,REDIS_CMD_LOADING, "loading");
flagcount += replyCmdFlag(c,cmd,REDIS_CMD_STALE, "stale"); flagcount += addReplyCommandFlag(c,cmd,REDIS_CMD_STALE, "stale");
flagcount += replyCmdFlag(c,cmd,REDIS_CMD_SKIP_MONITOR, "skipmonitor"); flagcount += addReplyCommandFlag(c,cmd,REDIS_CMD_SKIP_MONITOR, "skip_monitor");
flagcount += replyCmdFlag(c,cmd,REDIS_CMD_ASKING, "asking"); flagcount += addReplyCommandFlag(c,cmd,REDIS_CMD_ASKING, "asking");
if (cmd->getkeys_proc) { if (cmd->getkeys_proc) {
addReplyStatus(c, "movablekeys"); addReplyStatus(c, "movablekeys");
flagcount += 1; flagcount += 1;
...@@ -2309,6 +2309,7 @@ static void replyCmd(redisClient *c, struct redisCommand *cmd) { ...@@ -2309,6 +2309,7 @@ static void replyCmd(redisClient *c, struct redisCommand *cmd) {
addReplyLongLong(c, cmd->keystep); addReplyLongLong(c, cmd->keystep);
} }
} }
void commandsCommand(redisClient *c) { void commandsCommand(redisClient *c) {
dictIterator *di; dictIterator *di;
dictEntry *de; dictEntry *de;
...@@ -2317,7 +2318,7 @@ void commandsCommand(redisClient *c) { ...@@ -2317,7 +2318,7 @@ void commandsCommand(redisClient *c) {
int i; int i;
addReplyMultiBulkLen(c, c->argc-2); addReplyMultiBulkLen(c, c->argc-2);
for (i = 2; i < c->argc; i++) { for (i = 2; i < c->argc; i++) {
replyCmd(c, dictFetchValue(server.commands, c->argv[i]->ptr)); addReplyCommand(c, dictFetchValue(server.commands, c->argv[i]->ptr));
} }
} else if (c->argc > 2) { } else if (c->argc > 2) {
addReplyError(c, "Unknown subcommand."); addReplyError(c, "Unknown subcommand.");
...@@ -2326,13 +2327,12 @@ void commandsCommand(redisClient *c) { ...@@ -2326,13 +2327,12 @@ void commandsCommand(redisClient *c) {
addReplyMultiBulkLen(c, dictSize(server.commands)); addReplyMultiBulkLen(c, dictSize(server.commands));
di = dictGetIterator(server.commands); di = dictGetIterator(server.commands);
while ((de = dictNext(di)) != NULL) { while ((de = dictNext(di)) != NULL) {
replyCmd(c, dictGetVal(de)); addReplyCommand(c, dictGetVal(de));
} }
dictReleaseIterator(di); dictReleaseIterator(di);
} }
} }
/* Convert an amount of bytes into a human readable string in the form /* Convert an amount of bytes into a human readable string in the form
* of 100B, 2G, 100M, 4K, and so forth. */ * of 100B, 2G, 100M, 4K, and so forth. */
void bytesToHuman(char *s, unsigned long long n) { void bytesToHuman(char *s, unsigned long long n) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment