Fixed Client::stop problem with more than one requests on threads

This commit is contained in:
yhirose 2020-06-12 11:04:37 -04:00
parent ec00fe5d5b
commit 5af7222217
2 changed files with 71 additions and 42 deletions

View file

@ -1766,14 +1766,19 @@ TEST_F(ServerTest, GetStreamedEndless) {
}
TEST_F(ServerTest, ClientStop) {
thread t = thread([&]() {
auto res = cli_.Get("/streamed-cancel",
[&](const char *, uint64_t) { return true; });
ASSERT_TRUE(res == nullptr);
});
std::vector<std::thread> threads;
for (auto i = 0; i < 10; i++) {
threads.emplace_back(thread([&]() {
auto res = cli_.Get("/streamed-cancel",
[&](const char *, uint64_t) { return true; });
ASSERT_TRUE(res == nullptr);
}));
}
std::this_thread::sleep_for(std::chrono::seconds(1));
cli_.stop();
t.join();
for (auto& t: threads) {
t.join();
}
}
TEST_F(ServerTest, GetWithRange1) {