Commit 09327ee6 authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Merge branch 'fix_promise_timeout' into 'develop'

Avoid freezing SMF with a timeout

See merge request oai/cn5g/oai-cn5g-smf!152
parents adf950ad 444e7c09
......@@ -1322,13 +1322,18 @@ void smf_sbi::curl_release_handles() {
//---------------------------------------------------------------------------------------------
uint32_t smf_sbi::get_available_response(boost::shared_future<uint32_t>& f) {
f.wait(); // Wait for it to finish
assert(f.is_ready());
assert(f.has_value());
assert(!f.has_exception());
uint32_t response_code = f.get();
return response_code;
boost::future_status status;
// wait for timeout or ready
status = f.wait_for(boost::chrono::milliseconds(FUTURE_STATUS_TIMEOUT_MS));
if (status == boost::future_status::ready) {
assert(f.is_ready());
assert(f.has_value());
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