| 526 | } |
| 527 | |
| 528 | bool _waitForShards() { |
| 529 | bool badShard = false; |
| 530 | { |
| 531 | const std::lock_guard<std::mutex> lock(_shared.shardsMutex); |
| 532 | for (int i = 0; i < _shared.shards.size(); i++) { |
| 533 | const auto sh = _shared.shards[i]; |
| 534 | if (sh.addrs[0].port == 0) { |
| 535 | LOG_DEBUG(_env, "Shard %s isn't ready yet", i); |
| 536 | badShard = true; |
| 537 | break; |
| 538 | } |
| 539 | } |
| 540 | } |
| 541 | if (badShard) { |
| 542 | (100_ms).sleep(); |
| 543 | return false; |
| 544 | } |
| 545 | |
| 546 | LOG_INFO(_env, "shards found, proceeding"); |
| 547 | return true; |
| 548 | } |
| 549 | |
| 550 | // To be called when we have a shard response with given `reqId`. |
| 551 | // Searches it in the in flight map, removes it from it, and |