Commit 444e7c09 authored by Tien Thinh NGUYEN's avatar Tien Thinh NGUYEN

Avoid freezing SMF with a timeout

parent adf950ad
...@@ -1322,13 +1322,18 @@ void smf_sbi::curl_release_handles() { ...@@ -1322,13 +1322,18 @@ void smf_sbi::curl_release_handles() {
//--------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------
uint32_t smf_sbi::get_available_response(boost::shared_future<uint32_t>& f) { uint32_t smf_sbi::get_available_response(boost::shared_future<uint32_t>& f) {
f.wait(); // Wait for it to finish boost::future_status status;
assert(f.is_ready()); // wait for timeout or ready
assert(f.has_value()); status = f.wait_for(boost::chrono::milliseconds(FUTURE_STATUS_TIMEOUT_MS));
assert(!f.has_exception()); if (status == boost::future_status::ready) {
assert(f.is_ready());
uint32_t response_code = f.get(); assert(f.has_value());
return response_code; assert(!f.has_exception());
uint32_t response_code = f.get();
return response_code;
} else {
return 408; // timeout, TODO: remove hardcoded value
}
} }
//--------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment