| 561 | } |
| 562 | |
| 563 | redis_slot* redis_cluster::get_slot_master(const redis_result* rr) |
| 564 | { |
| 565 | size_t size; |
| 566 | const redis_result** children = rr->get_children(&size); |
| 567 | if (children == NULL) { |
| 568 | return NULL; |
| 569 | } |
| 570 | if (size < 3) { |
| 571 | return NULL; |
| 572 | } |
| 573 | |
| 574 | int slot_min = children[0]->get_integer(); |
| 575 | if (slot_min < 0) { |
| 576 | return NULL; |
| 577 | } |
| 578 | |
| 579 | int slot_max = children[1]->get_integer(); |
| 580 | if (slot_max < slot_min) { |
| 581 | return NULL; |
| 582 | } |
| 583 | |
| 584 | redis_slot* master = get_slot(children[2], slot_max, slot_min); |
| 585 | if (master == NULL) { |
| 586 | return NULL; |
| 587 | } |
| 588 | |
| 589 | for (size_t i = 3; i < size; i++) { |
| 590 | redis_slot* slave = get_slot(children[i], slot_max, slot_min); |
| 591 | if (slave != NULL) { |
| 592 | master->add_slave(slave); |
| 593 | } |
| 594 | } |
| 595 | |
| 596 | return master; |
| 597 | } |
| 598 | |
| 599 | redis_slot* redis_cluster::get_slot(const redis_result* rr, |
| 600 | size_t slot_max, size_t slot_min) |
nothing calls this directly
no test coverage detected