MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / updateClusterSlotsConfiguration

Function updateClusterSlotsConfiguration

src/redis-benchmark.cpp:1392–1411  ·  view source on GitHub ↗

Atomically update the new slots configuration. */

Source from the content-addressed store, hash-verified

1390
1391/* Atomically update the new slots configuration. */
1392static void updateClusterSlotsConfiguration() {
1393 pthread_mutex_lock(&config.is_updating_slots_mutex);
1394 atomicSet(config.is_updating_slots, 1);
1395 int i;
1396 for (i = 0; i < config.cluster_node_count; i++) {
1397 clusterNode *node = config.cluster_nodes[i];
1398 if (node->updated_slots != NULL) {
1399 int *oldslots = node->slots;
1400 node->slots = node->updated_slots;
1401 node->slots_count = node->updated_slots_count;
1402 node->current_slot_index = 0;
1403 node->updated_slots = NULL;
1404 node->updated_slots_count = 0;
1405 zfree(oldslots);
1406 }
1407 }
1408 atomicSet(config.is_updating_slots, 0);
1409 atomicIncr(config.slots_last_update, 1);
1410 pthread_mutex_unlock(&config.is_updating_slots_mutex);
1411}
1412
1413/* Generate random data for redis benchmark. See #7196. */
1414static void genBenchmarkRandomData(char *data, int count) {

Callers 2

setClusterKeyHashTagFunction · 0.85

Calls 1

zfreeFunction · 0.85

Tested by

no test coverage detected