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. */
| 3282 | * MIGRATE command, or NULL if something goes wrong. If the argument 'dots' |
| 3283 | * is not NULL, a dot will be printed for every migrated key. */ |
| 3284 | static redisReply *clusterManagerMigrateKeysInReply(clusterManagerNode *source, |
| 3285 | clusterManagerNode *target, |
| 3286 | redisReply *reply, |
| 3287 | int replace, int timeout, |
| 3288 | char *dots) |
| 3289 | { |
| 3290 | redisReply *migrate_reply = NULL; |
| 3291 | char **argv = NULL; |
| 3292 | size_t *argv_len = NULL; |
| 3293 | int c = (replace ? 8 : 7); |
| 3294 | if (config.auth) c += 2; |
| 3295 | if (config.user) c += 1; |
| 3296 | size_t argc = c + reply->elements; |
| 3297 | size_t i, offset = 6; // Keys Offset |
| 3298 | argv = zcalloc(argc * sizeof(char *), MALLOC_LOCAL); |
| 3299 | argv_len = zcalloc(argc * sizeof(size_t), MALLOC_LOCAL); |
| 3300 | char portstr[255]; |
| 3301 | char timeoutstr[255]; |
| 3302 | snprintf(portstr, sizeof(portstr), "%d", target->port); |
| 3303 | snprintf(timeoutstr, sizeof(timeoutstr), "%d", timeout); |
| 3304 | argv[0] = "MIGRATE"; |
| 3305 | argv_len[0] = 7; |
| 3306 | argv[1] = target->ip; |
| 3307 | argv_len[1] = strlen(target->ip); |
| 3308 | argv[2] = portstr; |
| 3309 | argv_len[2] = strlen(portstr); |
| 3310 | argv[3] = ""; |
| 3311 | argv_len[3] = 0; |
| 3312 | argv[4] = "0"; |
| 3313 | argv_len[4] = 1; |
| 3314 | argv[5] = timeoutstr; |
| 3315 | argv_len[5] = strlen(timeoutstr); |
| 3316 | if (replace) { |
| 3317 | argv[offset] = "REPLACE"; |
| 3318 | argv_len[offset] = 7; |
| 3319 | offset++; |
| 3320 | } |
| 3321 | if (config.auth) { |
| 3322 | if (config.user) { |
| 3323 | argv[offset] = "AUTH2"; |
| 3324 | argv_len[offset] = 5; |
| 3325 | offset++; |
| 3326 | argv[offset] = config.user; |
| 3327 | argv_len[offset] = strlen(config.user); |
| 3328 | offset++; |
| 3329 | argv[offset] = config.auth; |
| 3330 | argv_len[offset] = strlen(config.auth); |
| 3331 | offset++; |
| 3332 | } else { |
| 3333 | argv[offset] = "AUTH"; |
| 3334 | argv_len[offset] = 4; |
| 3335 | offset++; |
| 3336 | argv[offset] = config.auth; |
| 3337 | argv_len[offset] = strlen(config.auth); |
| 3338 | offset++; |
| 3339 | } |
| 3340 | } |
| 3341 | argv[offset] = "KEYS"; |
no test coverage detected