mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-15 01:08:27 +00:00
Fixed Client::stop problem with more than one requests on threads
This commit is contained in:
parent
ec00fe5d5b
commit
5af7222217
2 changed files with 71 additions and 42 deletions
17
test/test.cc
17
test/test.cc
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue