Skip to content

Commit 08296ec

Browse files
committed
fix recv_with_timeout
1 parent f4dab52 commit 08296ec

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

examples/server/server.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,10 +1642,6 @@ struct server_response {
16421642
server_task_result_ptr recv_with_timeout(const std::unordered_set<int> & id_tasks, int timeout) {
16431643
while (true) {
16441644
std::unique_lock<std::mutex> lock(mutex_results);
1645-
std::cv_status cr_res = condition_results.wait_for(lock, std::chrono::seconds(timeout));
1646-
if (cr_res == std::cv_status::timeout) {
1647-
return nullptr;
1648-
}
16491645

16501646
for (int i = 0; i < (int) queue_results.size(); i++) {
16511647
if (id_tasks.find(queue_results[i]->id) != id_tasks.end()) {
@@ -1654,6 +1650,11 @@ struct server_response {
16541650
return res;
16551651
}
16561652
}
1653+
1654+
std::cv_status cr_res = condition_results.wait_for(lock, std::chrono::seconds(timeout));
1655+
if (cr_res == std::cv_status::timeout) {
1656+
return nullptr;
1657+
}
16571658
}
16581659

16591660
// should never reach here

0 commit comments

Comments
 (0)