Major new Client fixes.

GitOrigin-RevId: 34c263a4adb3c312328530e1382108d98e9048a3
This commit is contained in:
levlam 2020-07-30 23:39:10 +03:00
parent 9ab0880680
commit 871fe2210d
2 changed files with 4 additions and 4 deletions

View File

@ -280,7 +280,7 @@ class TdReceiver {
}
if (timeout != 0) {
output_queue_->reader_get_event_fd().wait(static_cast<int>(timeout * 1000));
return receive(0);
return receive_unlocked(0);
}
return {0, 0, nullptr};
}
@ -357,6 +357,8 @@ class MultiImplPool {
std::shared_ptr<MultiImpl> get() {
std::unique_lock<std::mutex> lock(mutex_);
if (impls_.empty()) {
init_openssl_threads();
impls_.resize(clamp(thread::hardware_concurrency(), 8u, 1000u) * 5 / 4);
}
auto &impl = *std::min_element(impls_.begin(), impls_.end(),
@ -476,8 +478,6 @@ class Client::Impl final {
#endif
Client::Client() : impl_(std::make_unique<Impl>()) {
// At least it should be enough for everybody who uses TDLib
init_openssl_threads();
}
void Client::send(Request &&request) {

View File

@ -915,7 +915,7 @@ TEST(Client, MultiNew) {
}
std::set<int32> ids;
while (ids.size() * threads_n * clients_n) {
while (ids.size() != static_cast<size_t>(threads_n) * clients_n) {
auto event = client.receive(10);
if (event.client_id != 0 && event.id == 3) {
ids.insert(event.client_id);