| 431 | }; |
| 432 | |
| 433 | void* select_server(void* arg) { |
| 434 | SelectArg *sa = (SelectArg*)arg; |
| 435 | brpc::LoadBalancer* c = sa->lb; |
| 436 | brpc::SocketUniquePtr ptr; |
| 437 | CountMap *selected_count = new CountMap; |
| 438 | brpc::LoadBalancer::SelectIn in = { 0, false, false, 0u, NULL }; |
| 439 | brpc::LoadBalancer::SelectOut out(&ptr); |
| 440 | uint32_t rand_seed = rand(); |
| 441 | if (sa->hash) { |
| 442 | uint32_t rd = ++rand_seed; |
| 443 | in.has_request_code = true; |
| 444 | in.request_code = sa->hash((const char *)&rd, sizeof(uint32_t)); |
| 445 | } |
| 446 | int ret = 0; |
| 447 | while (!global_stop && (ret = c->SelectServer(in, &out)) == 0) { |
| 448 | if (sa->hash) { |
| 449 | uint32_t rd = ++rand_seed; |
| 450 | in.has_request_code = true; |
| 451 | in.request_code = sa->hash((const char *)&rd, sizeof(uint32_t)); |
| 452 | } |
| 453 | ++(*selected_count)[ptr->id()]; |
| 454 | } |
| 455 | LOG_IF(INFO, ret != 0) << "select_server[" << pthread_self() |
| 456 | << "] quits before of " << berror(ret); |
| 457 | return selected_count; |
| 458 | } |
| 459 | |
| 460 | brpc::SocketId recycled_sockets[1024]; |
| 461 | butil::atomic<size_t> nrecycle(0); |
nothing calls this directly
no test coverage detected