"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/redis-cli.c" between
redis-6.0.7.tar.gz and redis-6.0.8.tar.gz

About: redis is an advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.

redis-cli.c  (redis-6.0.7):redis-cli.c  (redis-6.0.8)
skipping to change at line 128 skipping to change at line 128
#define CLUSTER_MANAGER_CMD_FLAG_SLAVE 1 << 1 #define CLUSTER_MANAGER_CMD_FLAG_SLAVE 1 << 1
#define CLUSTER_MANAGER_CMD_FLAG_YES 1 << 2 #define CLUSTER_MANAGER_CMD_FLAG_YES 1 << 2
#define CLUSTER_MANAGER_CMD_FLAG_AUTOWEIGHTS 1 << 3 #define CLUSTER_MANAGER_CMD_FLAG_AUTOWEIGHTS 1 << 3
#define CLUSTER_MANAGER_CMD_FLAG_EMPTYMASTER 1 << 4 #define CLUSTER_MANAGER_CMD_FLAG_EMPTYMASTER 1 << 4
#define CLUSTER_MANAGER_CMD_FLAG_SIMULATE 1 << 5 #define CLUSTER_MANAGER_CMD_FLAG_SIMULATE 1 << 5
#define CLUSTER_MANAGER_CMD_FLAG_REPLACE 1 << 6 #define CLUSTER_MANAGER_CMD_FLAG_REPLACE 1 << 6
#define CLUSTER_MANAGER_CMD_FLAG_COPY 1 << 7 #define CLUSTER_MANAGER_CMD_FLAG_COPY 1 << 7
#define CLUSTER_MANAGER_CMD_FLAG_COLOR 1 << 8 #define CLUSTER_MANAGER_CMD_FLAG_COLOR 1 << 8
#define CLUSTER_MANAGER_CMD_FLAG_CHECK_OWNERS 1 << 9 #define CLUSTER_MANAGER_CMD_FLAG_CHECK_OWNERS 1 << 9
#define CLUSTER_MANAGER_CMD_FLAG_FIX_WITH_UNREACHABLE_MASTERS 1 << 10 #define CLUSTER_MANAGER_CMD_FLAG_FIX_WITH_UNREACHABLE_MASTERS 1 << 10
#define CLUSTER_MANAGER_CMD_FLAG_MASTERS_ONLY 1 << 11
#define CLUSTER_MANAGER_CMD_FLAG_SLAVES_ONLY 1 << 12
#define CLUSTER_MANAGER_OPT_GETFRIENDS 1 << 0 #define CLUSTER_MANAGER_OPT_GETFRIENDS 1 << 0
#define CLUSTER_MANAGER_OPT_COLD 1 << 1 #define CLUSTER_MANAGER_OPT_COLD 1 << 1
#define CLUSTER_MANAGER_OPT_UPDATE 1 << 2 #define CLUSTER_MANAGER_OPT_UPDATE 1 << 2
#define CLUSTER_MANAGER_OPT_QUIET 1 << 6 #define CLUSTER_MANAGER_OPT_QUIET 1 << 6
#define CLUSTER_MANAGER_OPT_VERBOSE 1 << 7 #define CLUSTER_MANAGER_OPT_VERBOSE 1 << 7
#define CLUSTER_MANAGER_LOG_LVL_INFO 1 #define CLUSTER_MANAGER_LOG_LVL_INFO 1
#define CLUSTER_MANAGER_LOG_LVL_WARN 2 #define CLUSTER_MANAGER_LOG_LVL_WARN 2
#define CLUSTER_MANAGER_LOG_LVL_ERR 3 #define CLUSTER_MANAGER_LOG_LVL_ERR 3
skipping to change at line 1544 skipping to change at line 1546
} else if (!strcmp(argv[i],"--cluster") && !lastarg) { } else if (!strcmp(argv[i],"--cluster") && !lastarg) {
if (CLUSTER_MANAGER_MODE()) usage(); if (CLUSTER_MANAGER_MODE()) usage();
char *cmd = argv[++i]; char *cmd = argv[++i];
int j = i; int j = i;
while (j < argc && argv[j][0] != '-') j++; while (j < argc && argv[j][0] != '-') j++;
if (j > i) j--; if (j > i) j--;
createClusterManagerCommand(cmd, j - i, argv + i + 1); createClusterManagerCommand(cmd, j - i, argv + i + 1);
i = j; i = j;
} else if (!strcmp(argv[i],"--cluster") && lastarg) { } else if (!strcmp(argv[i],"--cluster") && lastarg) {
usage(); usage();
} else if ((!strcmp(argv[i],"--cluster-only-masters"))) {
config.cluster_manager_command.flags |=
CLUSTER_MANAGER_CMD_FLAG_MASTERS_ONLY;
} else if ((!strcmp(argv[i],"--cluster-only-replicas"))) {
config.cluster_manager_command.flags |=
CLUSTER_MANAGER_CMD_FLAG_SLAVES_ONLY;
} else if (!strcmp(argv[i],"--cluster-replicas") && !lastarg) { } else if (!strcmp(argv[i],"--cluster-replicas") && !lastarg) {
config.cluster_manager_command.replicas = atoi(argv[++i]); config.cluster_manager_command.replicas = atoi(argv[++i]);
} else if (!strcmp(argv[i],"--cluster-master-id") && !lastarg) { } else if (!strcmp(argv[i],"--cluster-master-id") && !lastarg) {
config.cluster_manager_command.master_id = argv[++i]; config.cluster_manager_command.master_id = argv[++i];
} else if (!strcmp(argv[i],"--cluster-from") && !lastarg) { } else if (!strcmp(argv[i],"--cluster-from") && !lastarg) {
config.cluster_manager_command.from = argv[++i]; config.cluster_manager_command.from = argv[++i];
} else if (!strcmp(argv[i],"--cluster-to") && !lastarg) { } else if (!strcmp(argv[i],"--cluster-to") && !lastarg) {
config.cluster_manager_command.to = argv[++i]; config.cluster_manager_command.to = argv[++i];
} else if (!strcmp(argv[i],"--cluster-weight") && !lastarg) { } else if (!strcmp(argv[i],"--cluster-weight") && !lastarg) {
if (config.cluster_manager_command.weight != NULL) { if (config.cluster_manager_command.weight != NULL) {
skipping to change at line 2321 skipping to change at line 2329
{"reshard", clusterManagerCommandReshard, -1, "host:port", {"reshard", clusterManagerCommandReshard, -1, "host:port",
"from <arg>,to <arg>,slots <arg>,yes,timeout <arg>,pipeline <arg>," "from <arg>,to <arg>,slots <arg>,yes,timeout <arg>,pipeline <arg>,"
"replace"}, "replace"},
{"rebalance", clusterManagerCommandRebalance, -1, "host:port", {"rebalance", clusterManagerCommandRebalance, -1, "host:port",
"weight <node1=w1...nodeN=wN>,use-empty-masters," "weight <node1=w1...nodeN=wN>,use-empty-masters,"
"timeout <arg>,simulate,pipeline <arg>,threshold <arg>,replace"}, "timeout <arg>,simulate,pipeline <arg>,threshold <arg>,replace"},
{"add-node", clusterManagerCommandAddNode, 2, {"add-node", clusterManagerCommandAddNode, 2,
"new_host:new_port existing_host:existing_port", "slave,master-id <arg>"}, "new_host:new_port existing_host:existing_port", "slave,master-id <arg>"},
{"del-node", clusterManagerCommandDeleteNode, 2, "host:port node_id",NULL}, {"del-node", clusterManagerCommandDeleteNode, 2, "host:port node_id",NULL},
{"call", clusterManagerCommandCall, -2, {"call", clusterManagerCommandCall, -2,
"host:port command arg arg .. arg", NULL}, "host:port command arg arg .. arg", "only-masters,only-replicas"},
{"set-timeout", clusterManagerCommandSetTimeout, 2, {"set-timeout", clusterManagerCommandSetTimeout, 2,
"host:port milliseconds", NULL}, "host:port milliseconds", NULL},
{"import", clusterManagerCommandImport, 1, "host:port", {"import", clusterManagerCommandImport, 1, "host:port",
"from <arg>,copy,replace"}, "from <arg>,copy,replace"},
{"backup", clusterManagerCommandBackup, 2, "host:port backup_directory", {"backup", clusterManagerCommandBackup, 2, "host:port backup_directory",
NULL}, NULL},
{"help", clusterManagerCommandHelp, 0, NULL, NULL} {"help", clusterManagerCommandHelp, 0, NULL, NULL}
}; };
static void getRDB(clusterManagerNode *node); static void getRDB(clusterManagerNode *node);
skipping to change at line 6422 skipping to change at line 6430
for (i = 0; i < argc; i++) { for (i = 0; i < argc; i++) {
argvlen[i] = strlen(argv[i]); argvlen[i] = strlen(argv[i]);
printf(" %s", argv[i]); printf(" %s", argv[i]);
} }
printf("\n"); printf("\n");
listIter li; listIter li;
listNode *ln; listNode *ln;
listRewind(cluster_manager.nodes, &li); listRewind(cluster_manager.nodes, &li);
while ((ln = listNext(&li)) != NULL) { while ((ln = listNext(&li)) != NULL) {
clusterManagerNode *n = ln->value; clusterManagerNode *n = ln->value;
if ((config.cluster_manager_command.flags & CLUSTER_MANAGER_CMD_FLAG_MAS
TERS_ONLY)
&& (n->replicate != NULL)) continue; // continue if node is slave
if ((config.cluster_manager_command.flags & CLUSTER_MANAGER_CMD_FLAG_SLA
VES_ONLY)
&& (n->replicate == NULL)) continue; // continue if node is mast
er
if (!n->context && !clusterManagerNodeConnect(n)) continue; if (!n->context && !clusterManagerNodeConnect(n)) continue;
redisReply *reply = NULL; redisReply *reply = NULL;
redisAppendCommandArgv(n->context, argc, (const char **) argv, argvlen); redisAppendCommandArgv(n->context, argc, (const char **) argv, argvlen);
int status = redisGetReply(n->context, (void **)(&reply)); int status = redisGetReply(n->context, (void **)(&reply));
if (status != REDIS_OK || reply == NULL ) if (status != REDIS_OK || reply == NULL )
printf("%s:%d: Failed!\n", n->ip, n->port); printf("%s:%d: Failed!\n", n->ip, n->port);
else { else {
sds formatted_reply = cliFormatReplyRaw(reply); sds formatted_reply = cliFormatReplyRaw(reply);
printf("%s:%d: %s\n", n->ip, n->port, (char *) formatted_reply); printf("%s:%d: %s\n", n->ip, n->port, (char *) formatted_reply);
sdsfree(formatted_reply); sdsfree(formatted_reply);
skipping to change at line 6809 skipping to change at line 6821
*/ */
/* Write a raw buffer through a redisContext. If we already have something /* Write a raw buffer through a redisContext. If we already have something
* in the buffer (leftovers from hiredis operations) it will be written * in the buffer (leftovers from hiredis operations) it will be written
* as well. * as well.
*/ */
static ssize_t writeConn(redisContext *c, const char *buf, size_t buf_len) static ssize_t writeConn(redisContext *c, const char *buf, size_t buf_len)
{ {
int done = 0; int done = 0;
/* Append data to buffer which is *usually* expected to be empty
* but we don't assume that, and write.
*/
c->obuf = sdscatlen(c->obuf, buf, buf_len); c->obuf = sdscatlen(c->obuf, buf, buf_len);
if (redisBufferWrite(c, &done) == REDIS_ERR) { if (redisBufferWrite(c, &done) == REDIS_ERR) {
sdsrange(c->obuf, 0, -(buf_len+1));
if (!(c->flags & REDIS_BLOCK)) if (!(c->flags & REDIS_BLOCK))
errno = EAGAIN; errno = EAGAIN;
/* On error, we assume nothing was written and we roll back the
* buffer to its original state.
*/
if (sdslen(c->obuf) > buf_len)
sdsrange(c->obuf, 0, -(buf_len+1));
else
sdsclear(c->obuf);
return -1; return -1;
} }
size_t left = sdslen(c->obuf); /* If we're done, free up everything. We may have written more than
sdsclear(c->obuf); * buf_len (if c->obuf was not initially empty) but we don't have to
if (!done) { * tell.
return buf_len - left; */
if (done) {
sdsclear(c->obuf);
return buf_len;
}
/* Write was successful but we have some leftovers which we should
* remove from the buffer.
*
* Do we still have data that was there prior to our buf? If so,
* restore buffer to it's original state and report no new data was
* writen.
*/
if (sdslen(c->obuf) > buf_len) {
sdsrange(c->obuf, 0, -(buf_len+1));
return 0;
} }
return buf_len; /* At this point we're sure no prior data is left. We flush the buffer
* and report how much we've written.
*/
size_t left = sdslen(c->obuf);
sdsclear(c->obuf);
return buf_len - left;
} }
/* Read raw bytes through a redisContext. The read operation is not greedy /* Read raw bytes through a redisContext. The read operation is not greedy
* and may not fill the buffer entirely. * and may not fill the buffer entirely.
*/ */
static ssize_t readConn(redisContext *c, char *buf, size_t len) static ssize_t readConn(redisContext *c, char *buf, size_t len)
{ {
return c->funcs->read(c, buf, len); return c->funcs->read(c, buf, len);
} }
 End of changes. 9 change blocks. 
7 lines changed or deleted 53 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)