| 455 | } |
| 456 | |
| 457 | const std::vector<disque_node*>* disque::hello() |
| 458 | { |
| 459 | free_nodes(); |
| 460 | |
| 461 | size_t argc = 1; |
| 462 | const char* argv[1]; |
| 463 | size_t lens[1]; |
| 464 | |
| 465 | argv[0] = "HELLO"; |
| 466 | lens[0] = sizeof("HELLO") - 1; |
| 467 | |
| 468 | build_request(argc, argv, lens); |
| 469 | const redis_result* rr = run(); |
| 470 | if (rr == NULL) { |
| 471 | return NULL; |
| 472 | } |
| 473 | |
| 474 | size_t n; |
| 475 | const redis_result** children = rr->get_children(&n); |
| 476 | if (children == NULL || n < 3) { |
| 477 | return NULL; |
| 478 | } |
| 479 | |
| 480 | if (children[0]->get_type() == REDIS_RESULT_INTEGER) { |
| 481 | version_ = children[0]->get_integer(); |
| 482 | } |
| 483 | |
| 484 | if (children[1]->get_type() == REDIS_RESULT_STRING) { |
| 485 | children[1]->argv_to_string(myid_); |
| 486 | } |
| 487 | |
| 488 | for (size_t i = 2; i < n; i++) { |
| 489 | disque_node* node = create_node(children[i]); |
| 490 | if (node != NULL) { |
| 491 | nodes_.push_back(node); |
| 492 | } |
| 493 | } |
| 494 | return &nodes_; |
| 495 | } |
| 496 | |
| 497 | disque_node* disque::create_node(const redis_result* rr) |
| 498 | { |