MCPcopy Create free account
hub / github.com/F-Stack/f-stack / clusterManagerMigrateKeysInReply

Function clusterManagerMigrateKeysInReply

app/redis-6.2.6/src/redis-cli.c:3673–3753  ·  view source on GitHub ↗

Migrate keys taken from reply->elements. It returns the reply from the * MIGRATE command, or NULL if something goes wrong. If the argument 'dots' * is not NULL, a dot will be printed for every migrated key. */

Source from the content-addressed store, hash-verified

3671 * MIGRATE command, or NULL if something goes wrong. If the argument 'dots'
3672 * is not NULL, a dot will be printed for every migrated key. */
3673static redisReply *clusterManagerMigrateKeysInReply(clusterManagerNode *source,
3674 clusterManagerNode *target,
3675 redisReply *reply,
3676 int replace, int timeout,
3677 char *dots)
3678{
3679 redisReply *migrate_reply = NULL;
3680 char **argv = NULL;
3681 size_t *argv_len = NULL;
3682 int c = (replace ? 8 : 7);
3683 if (config.auth) c += 2;
3684 if (config.user) c += 1;
3685 size_t argc = c + reply->elements;
3686 size_t i, offset = 6; // Keys Offset
3687 argv = zcalloc(argc * sizeof(char *));
3688 argv_len = zcalloc(argc * sizeof(size_t));
3689 char portstr[255];
3690 char timeoutstr[255];
3691 snprintf(portstr, 10, "%d", target->port);
3692 snprintf(timeoutstr, 10, "%d", timeout);
3693 argv[0] = "MIGRATE";
3694 argv_len[0] = 7;
3695 argv[1] = target->ip;
3696 argv_len[1] = strlen(target->ip);
3697 argv[2] = portstr;
3698 argv_len[2] = strlen(portstr);
3699 argv[3] = "";
3700 argv_len[3] = 0;
3701 argv[4] = "0";
3702 argv_len[4] = 1;
3703 argv[5] = timeoutstr;
3704 argv_len[5] = strlen(timeoutstr);
3705 if (replace) {
3706 argv[offset] = "REPLACE";
3707 argv_len[offset] = 7;
3708 offset++;
3709 }
3710 if (config.auth) {
3711 if (config.user) {
3712 argv[offset] = "AUTH2";
3713 argv_len[offset] = 5;
3714 offset++;
3715 argv[offset] = config.user;
3716 argv_len[offset] = strlen(config.user);
3717 offset++;
3718 argv[offset] = config.auth;
3719 argv_len[offset] = strlen(config.auth);
3720 offset++;
3721 } else {
3722 argv[offset] = "AUTH";
3723 argv_len[offset] = 4;
3724 offset++;
3725 argv[offset] = config.auth;
3726 argv_len[offset] = strlen(config.auth);
3727 offset++;
3728 }
3729 }
3730 argv[offset] = "KEYS";

Callers 1

Calls 7

snprintfFunction · 0.85
sdsnewlenFunction · 0.85
redisAppendCommandArgvFunction · 0.85
redisGetReplyFunction · 0.85
sdsfreeFunction · 0.85
zcallocFunction · 0.70
zfreeFunction · 0.70

Tested by

no test coverage detected