if(retval.code != RC_OK){
mdclog_write(MDCLOG_ERR, "%s, %d: Error decoding E2AP PDU of RMR type %d. Bytes decoded = %lu out of %d\n", __FILE__, __LINE__, message_type, retval.consumed, payload_length);
- return;
+ ASN_STRUCT_FREE(asn_DEF_E2AP_PDU, e2ap_recv);
+ return ;
}
type = e2ap_recv->present;
mdclog_write(MDCLOG_INFO, "Received RMR message of type = %d", type);
if(type == E2AP_PDU_PR_successfulOutcome){
-
+
procedureCode = e2ap_recv->choice.successfulOutcome->procedureCode;
mdclog_write(MDCLOG_INFO, "Received E2AP PDU successful outcome message with procedureCode = %d", procedureCode);
// subscription response
// decode the message
sub_resp.get_fields(e2ap_recv->choice.successfulOutcome, he_response);
+
{
std::lock_guard<std::mutex> lock(*(_data_lock.get()));
// get the id
id = he_response.get_request_id();
- if (get_request_status(id) == request_pending ){
+ // get status of id
+ int req_status = get_request_status(id);
+ if (req_status == request_pending ){
res = add_subscription_entry(id, he_response);
if(res)
set_request_status(id, request_success);
- else
+ else{
set_request_status(id, request_duplicate);
-
+ mdclog_write(MDCLOG_ERR, "Error:: %s, %d: Request %d seems to be a duplicate\n", __FILE__, __LINE__, id);
+ }
+
valid_response = true;
}
+ else if (req_status > 0){
+ // we don't change status of response since it was not in pending
+ // we simply fail
+ mdclog_write(MDCLOG_ERR, "Error:: %s, %d: Request %d is not in request_pending state, is in State = %d\n", __FILE__, __LINE__, id, req_status);
+
+ }
else{
- std::string error_string = "Could not find id to match response = ";
- mdclog_write(MDCLOG_ERR, "%s, %d: %s, %d", __FILE__, __LINE__, error_string.c_str(), id);
+ mdclog_write(MDCLOG_ERR, "%s, %d: Could not find id %d in request queue for subscription", __FILE__, __LINE__, id);
}
}
std::lock_guard<std::mutex> lock(*(_data_lock.get()));
// get the id
id = he_response.get_request_id();
- if (get_request_status(id) == delete_request_pending ){
+ int req_status = get_request_status(id);
+ if (req_status == delete_request_pending ){
// Remove the subscription from the table
res = delete_subscription_entry(id);
if(res){
valid_response = true;
}
else{
+ set_request_status(id, delete_request_failed);
std::string error_string = "Error deleting subscription entry for id = ";
mdclog_write(MDCLOG_ERR, "%s, %d: %s, %d", __FILE__, __LINE__, error_string.c_str(), id);
+ valid_response = true;
}
}
-
+ else if (req_status > 0){
+ // we don't change status since it was not in pending
+ // we simply fail
+ mdclog_write(MDCLOG_ERR, "Error:: %s, %d: Request %d for deletion is not in delete_pending state, is in State = %d\n", __FILE__, __LINE__, id, req_status);
+ }
else{
- std::string error_string = "Could not find id for deletion = ";
- mdclog_write(MDCLOG_ERR, "%s, %d: %s, %d", __FILE__, __LINE__, error_string.c_str(), id);
+ mdclog_write(MDCLOG_ERR, "%s, %d: Could not find id %d in request queue for deletion ", __FILE__, __LINE__, id);
}
}
- }
+ }
else{
- std::string error_string = "Handler received E2AP subscription message with Unknown procedure code =" ;
- mdclog_write(MDCLOG_ERR, "%s, %d: %s, %d", __FILE__, __LINE__, error_string.c_str(), procedureCode);
+ mdclog_write(MDCLOG_ERR, "%s, %d: Subscription Handler Response received E2AP PDU success response with an non-subscription response related type %d", __FILE__, __LINE__, procedureCode);
}
}
{
std::lock_guard<std::mutex> lock(*(_data_lock.get()));
id = he_response.get_request_id();
-
- if(get_request_status(id) == request_pending){
+ int req_status = get_request_status(id);
+ if(req_status == request_pending){
set_request_status(id, request_failed);
valid_response = true;
- mdclog_write(MDCLOG_INFO, "Subscription request %d failed", id);
+ mdclog_write(MDCLOG_ERR, "Subscription request %d failed", id);
+ }
+ else if (req_status > 0){
+ // we don't changet status since it was not in pending
+ // we simply fail
+ mdclog_write(MDCLOG_ERR, "Error:: %s, %d: Request %d is not in request_pending state, is in State = %d\n", __FILE__, __LINE__, id, req_status);
}
else{
- std::string error_string = "Could not find id to match response = ";
- mdclog_write(MDCLOG_ERR, "%s, %d: %s, %d", __FILE__, __LINE__, error_string.c_str(), id);
+ mdclog_write(MDCLOG_ERR, "%s, %d: Could not find id %d in request queue for subscription ", __FILE__, __LINE__, id);
}
}
}
std::lock_guard<std::mutex> lock(*(_data_lock.get()));
// get the id
id = he_response.get_request_id();
- if(get_request_status(id) == delete_request_pending){
+ int req_status = get_request_status(id);
+ if(req_status == delete_request_pending){
set_request_status(id, delete_request_failed);
mdclog_write(MDCLOG_INFO, "Subscription delete request %d failed", id);
valid_response = true;
}
+ else if (req_status > 0){
+ mdclog_write(MDCLOG_ERR, "Error:: %s, %d: Request %d for deletion is not in delete_pending state, is in State = %d\n", __FILE__, __LINE__, id, req_status);
+ }
else{
- std::string error_string = "Could not find id to match response = ";
- mdclog_write(MDCLOG_ERR, "%s, %d: %s, %d", __FILE__, __LINE__, error_string.c_str(), id);
- return;
+ mdclog_write(MDCLOG_ERR, "%s, %d: Could not find id %d in request queue for deletion ", __FILE__, __LINE__, id);
}
}
}
- }
+ else{
+ mdclog_write(MDCLOG_ERR, "%s, %d: Susbcription Handler Response received E2AP PDU failure response with a non-subscription response related type %d", __FILE__, __LINE__, procedureCode);
+
+ }
+ }
else{
- std::string error_string = "Handler received E2AP subscription message with Unknown procedure code =" ;
- mdclog_write(MDCLOG_ERR, "%s, %d: %s, %d", __FILE__, __LINE__, error_string.c_str(), procedureCode);
+ mdclog_write(MDCLOG_ERR, "%s, %d: Susbcription Handler Response received E2AP PDU with non response type %d", __FILE__, __LINE__, type);
}
// get a new unique request id ...
unsigned int new_req_id = get_next_id();
- std::cout <<"Using id = " << new_req_id << std::endl;
+ mdclog_write(MDCLOG_INFO, "%s, %d:: Generated new request id %d\n", __FILE__, __LINE__, new_req_id);
he.set_request(new_req_id, he.get_req_seq());
E2AP_PDU_t *e2ap_pdu = 0;
std::unique_lock<std::mutex> _local_lock(*(_data_lock.get()));
-
// Send the message
res = tx(TxCode, buf_len, buffer);
if (!res){
while(1){
-
- // wait to be woken up
+ // release lock and wait to be woken up
_cv.get()->wait_for(_local_lock, _time_out);
// we have woken and acquired data_lock
int status = get_request_status(he.get_request_id());
if (status == request_success){
+ // retreive the subscription response and clear queue
+ response = subscription_responses[he.get_request_id()];
+
+ // clear state
+ delete_request_entry(he.get_request_id());
+
+ // release data lock
+ _local_lock.unlock();
mdclog_write(MDCLOG_INFO, "Successfully subscribed for request %d", he.get_request_id());
+
break;
}
if (status == request_pending){
+
// woken up spuriously or timed out
auto end = std::chrono::system_clock::now();
std::chrono::duration<double> f = end - start;
if (_time_out_flag && f > _num_retries * _time_out){
delete_request_entry(he.get_request_id());
- mdclog_write(MDCLOG_ERR, "Subscription request %d timed out waiting for response ", he.get_request_id());
+ mdclog_write(MDCLOG_ERR, "%s, %d:: Subscription request %d timed out waiting for response ", __FILE__, __LINE__, he.get_request_id());
// Release data lock
_local_lock.unlock();
}
}
- // if we are hear, some spurious
+ // if we are here, some spurious
// status obtained or request failed . we return false
+ mdclog_write(MDCLOG_ERR, "Error :: %s, %d : Spurious time out caused by invalid state of request %d -- state = %d. Deleting request entry and failing .. \n", __FILE__, __LINE__, he.get_request_id(), status);
delete_request_entry(he.get_request_id());
// release data lock
};
- // retreive the subscription response and clear queue
- response = subscription_responses[he.get_request_id()];
- delete_request_entry(he.get_request_id());
-
- // release data lock
- _local_lock.unlock();
return true;
};