Fix ClientManager without EventFd.
This commit is contained in:
parent
d9607b4a46
commit
e6c4bc6ca4
@ -129,7 +129,7 @@ class ClientManager::Impl final {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto response = receiver_.receive(0);
|
auto response = receiver_.receive(0);
|
||||||
if (response.client_id == 0 && concurrent_scheduler_ != nullptr) {
|
if (response.client_id == 0 && response.request_id == 0 && concurrent_scheduler_ != nullptr) {
|
||||||
concurrent_scheduler_->run_main(0);
|
concurrent_scheduler_->run_main(0);
|
||||||
response = receiver_.receive(0);
|
response = receiver_.receive(0);
|
||||||
} else {
|
} else {
|
||||||
@ -188,7 +188,9 @@ class ClientManager::Impl final {
|
|||||||
while (!tds_.empty() && !ExitGuard::is_exited()) {
|
while (!tds_.empty() && !ExitGuard::is_exited()) {
|
||||||
receive(0.1);
|
receive(0.1);
|
||||||
}
|
}
|
||||||
concurrent_scheduler_->finish();
|
if (concurrent_scheduler_ != nullptr) {
|
||||||
|
concurrent_scheduler_->finish();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -936,7 +936,11 @@ TEST(Client, Multi) {
|
|||||||
TEST(Client, Manager) {
|
TEST(Client, Manager) {
|
||||||
td::vector<td::thread> threads;
|
td::vector<td::thread> threads;
|
||||||
td::ClientManager client;
|
td::ClientManager client;
|
||||||
|
#if !TD_EVENTFD_UNSUPPORTED // Client must be used from a single thread if there is no EventFd
|
||||||
int threads_n = 4;
|
int threads_n = 4;
|
||||||
|
#else
|
||||||
|
int threads_n = 1;
|
||||||
|
#endif
|
||||||
int clients_n = 1000;
|
int clients_n = 1000;
|
||||||
client.send(0, 3, td::make_tl_object<td::td_api::testSquareInt>(3));
|
client.send(0, 3, td::make_tl_object<td::td_api::testSquareInt>(3));
|
||||||
client.send(-1, 3, td::make_tl_object<td::td_api::testSquareInt>(3));
|
client.send(-1, 3, td::make_tl_object<td::td_api::testSquareInt>(3));
|
||||||
@ -969,6 +973,7 @@ TEST(Client, Manager) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !TD_EVENTFD_UNSUPPORTED // Client must be used from a single thread if there is no EventFd
|
||||||
TEST(Client, Close) {
|
TEST(Client, Close) {
|
||||||
std::atomic<bool> stop_send{false};
|
std::atomic<bool> stop_send{false};
|
||||||
std::atomic<bool> can_stop_receive{false};
|
std::atomic<bool> can_stop_receive{false};
|
||||||
@ -1093,6 +1098,7 @@ TEST(Client, ManagerClose) {
|
|||||||
ASSERT_TRUE(request_ids.empty());
|
ASSERT_TRUE(request_ids.empty());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
TEST(Client, ManagerCloseOneThread) {
|
TEST(Client, ManagerCloseOneThread) {
|
||||||
td::ClientManager client_manager;
|
td::ClientManager client_manager;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user