Commit 610acd8e authored by Tien-Thinh Nguyen's avatar Tien-Thinh Nguyen

Merge branch 'fix_timeout_pdu_session_release' into 'develop'

Fix issue when there's no valid reply from UPF for PDU session release

See merge request oai/cn5g/oai-cn5g-smf!155
parents c402156f 3ba7955a
...@@ -85,12 +85,22 @@ void IndividualSMContextApiImpl::release_sm_context( ...@@ -85,12 +85,22 @@ void IndividualSMContextApiImpl::release_sm_context(
itti_msg->http_version = 1; itti_msg->http_version = 1;
m_smf_app->handle_pdu_session_release_sm_context_request(itti_msg); m_smf_app->handle_pdu_session_release_sm_context_request(itti_msg);
// Wait for the result from APP and send reply to AMF boost::future_status status;
smf::pdu_session_release_sm_context_response sm_context_response = f.get(); // wait for timeout or ready
Logger::smf_api_server().debug("Got result for promise ID %d", promise_id); status = f.wait_for(boost::chrono::milliseconds(FUTURE_STATUS_TIMEOUT_MS));
if (status == boost::future_status::ready) {
// TODO: Process the response assert(f.is_ready());
response.send(Pistache::Http::Code(sm_context_response.get_http_code())); assert(f.has_value());
assert(!f.has_exception());
// Wait for the result from APP and send reply to NF consumer (e.g., AMF)
smf::pdu_session_release_sm_context_response sm_context_response = f.get();
Logger::smf_api_server().debug("Got result for promise ID %d", promise_id);
// TODO: Process the response
response.send(Pistache::Http::Code(sm_context_response.get_http_code()));
} else {
response.send(Pistache::Http::Code::Request_Timeout);
}
} }
void IndividualSMContextApiImpl::retrieve_sm_context( void IndividualSMContextApiImpl::retrieve_sm_context(
...@@ -138,54 +148,67 @@ void IndividualSMContextApiImpl::update_sm_context( ...@@ -138,54 +148,67 @@ void IndividualSMContextApiImpl::update_sm_context(
itti_msg->http_version = 1; itti_msg->http_version = 1;
m_smf_app->handle_pdu_session_update_sm_context_request(itti_msg); m_smf_app->handle_pdu_session_update_sm_context_request(itti_msg);
// Wait for the result from APP and send reply to AMF boost::future_status status;
smf::pdu_session_update_sm_context_response sm_context_response = f.get(); // wait for timeout or ready
Logger::smf_api_server().debug("Got result for promise ID %d", promise_id); status = f.wait_for(boost::chrono::milliseconds(FUTURE_STATUS_TIMEOUT_MS));
if (status == boost::future_status::ready) {
nlohmann::json json_data = {}; assert(f.is_ready());
std::string body = {}; assert(f.has_value());
std::string json_format; assert(!f.has_exception());
// Wait for the result from APP and send reply to NF consumer (e.g., AMF)
sm_context_response.get_json_format(json_format); smf::pdu_session_update_sm_context_response sm_context_response = f.get();
sm_context_response.get_json_data(json_data); Logger::smf_api_server().debug("Got result for promise ID %d", promise_id);
Logger::smf_api_server().debug("Json data %s", json_data.dump().c_str());
nlohmann::json json_data = {};
if (sm_context_response.n1_sm_msg_is_set() and std::string body = {};
sm_context_response.n2_sm_info_is_set()) { std::string json_format;
mime_parser::create_multipart_related_content(
body, json_data.dump(), CURL_MIME_BOUNDARY, sm_context_response.get_json_format(json_format);
sm_context_response.get_n1_sm_message(), sm_context_response.get_json_data(json_data);
sm_context_response.get_n2_sm_information(), json_format); Logger::smf_api_server().debug("Json data %s", json_data.dump().c_str());
response.headers().add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType( if (sm_context_response.n1_sm_msg_is_set() and
"multipart/related; boundary=" + std::string(CURL_MIME_BOUNDARY))); sm_context_response.n2_sm_info_is_set()) {
} else if (sm_context_response.n1_sm_msg_is_set()) { mime_parser::create_multipart_related_content(
mime_parser::create_multipart_related_content( body, json_data.dump(), CURL_MIME_BOUNDARY,
body, json_data.dump(), CURL_MIME_BOUNDARY, sm_context_response.get_n1_sm_message(),
sm_context_response.get_n1_sm_message(), sm_context_response.get_n2_sm_information(), json_format);
multipart_related_content_part_e::NAS, json_format); response.headers().add<Pistache::Http::Header::ContentType>(
response.headers().add<Pistache::Http::Header::ContentType>( Pistache::Http::Mime::MediaType(
Pistache::Http::Mime::MediaType( "multipart/related; boundary=" +
"multipart/related; boundary=" + std::string(CURL_MIME_BOUNDARY))); std::string(CURL_MIME_BOUNDARY)));
} else if (sm_context_response.n2_sm_info_is_set()) { } else if (sm_context_response.n1_sm_msg_is_set()) {
mime_parser::create_multipart_related_content( mime_parser::create_multipart_related_content(
body, json_data.dump(), CURL_MIME_BOUNDARY, body, json_data.dump(), CURL_MIME_BOUNDARY,
sm_context_response.get_n2_sm_information(), sm_context_response.get_n1_sm_message(),
multipart_related_content_part_e::NGAP, json_format); multipart_related_content_part_e::NAS, json_format);
response.headers().add<Pistache::Http::Header::ContentType>( response.headers().add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType( Pistache::Http::Mime::MediaType(
"multipart/related; boundary=" + std::string(CURL_MIME_BOUNDARY))); "multipart/related; boundary=" +
} else if (json_data.size() > 0) { std::string(CURL_MIME_BOUNDARY)));
response.headers().add<Pistache::Http::Header::ContentType>( } else if (sm_context_response.n2_sm_info_is_set()) {
Pistache::Http::Mime::MediaType(json_format)); mime_parser::create_multipart_related_content(
body = json_data.dump().c_str(); body, json_data.dump(), CURL_MIME_BOUNDARY,
sm_context_response.get_n2_sm_information(),
multipart_related_content_part_e::NGAP, json_format);
response.headers().add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType(
"multipart/related; boundary=" +
std::string(CURL_MIME_BOUNDARY)));
} else if (json_data.size() > 0) {
response.headers().add<Pistache::Http::Header::ContentType>(
Pistache::Http::Mime::MediaType(json_format));
body = json_data.dump().c_str();
} else {
response.send(Pistache::Http::Code(sm_context_response.get_http_code()));
return;
}
response.send(
Pistache::Http::Code(sm_context_response.get_http_code()), body);
} else { } else {
response.send(Pistache::Http::Code(sm_context_response.get_http_code())); response.send(Pistache::Http::Code::Request_Timeout);
return;
} }
response.send(
Pistache::Http::Code(sm_context_response.get_http_code()), body);
} }
} // namespace api } // namespace api
} // namespace smf_server } // namespace smf_server
......
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