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

Function updateClusterSlotsConfiguration

app/redis-6.2.6/src/redis-benchmark.c:1376–1395  ·  view source on GitHub ↗

Atomically update the new slots configuration. */

Source from the content-addressed store, hash-verified

1374
1375/* Atomically update the new slots configuration. */
1376static void updateClusterSlotsConfiguration() {
1377 pthread_mutex_lock(&config.is_updating_slots_mutex);
1378 atomicSet(config.is_updating_slots, 1);
1379 int i;
1380 for (i = 0; i < config.cluster_node_count; i++) {
1381 clusterNode *node = config.cluster_nodes[i];
1382 if (node->updated_slots != NULL) {
1383 int *oldslots = node->slots;
1384 node->slots = node->updated_slots;
1385 node->slots_count = node->updated_slots_count;
1386 node->current_slot_index = 0;
1387 node->updated_slots = NULL;
1388 node->updated_slots_count = 0;
1389 zfree(oldslots);
1390 }
1391 }
1392 atomicSet(config.is_updating_slots, 0);
1393 atomicIncr(config.slots_last_update, 1);
1394 pthread_mutex_unlock(&config.is_updating_slots_mutex);
1395}
1396
1397/* Generate random data for redis benchmark. See #7196. */
1398static void genBenchmarkRandomData(char *data, int count) {

Callers 2

setClusterKeyHashTagFunction · 0.85

Calls 3

pthread_mutex_lockFunction · 0.85
pthread_mutex_unlockFunction · 0.85
zfreeFunction · 0.70

Tested by

no test coverage detected