diff --git a/srsepc/src/mme/s1ap.cc b/srsepc/src/mme/s1ap.cc index c8f95d706..3a52e2cbe 100644 --- a/srsepc/src/mme/s1ap.cc +++ b/srsepc/src/mme/s1ap.cc @@ -431,23 +431,28 @@ s1ap::release_ues_ecm_ctx_in_enb(uint16_t enb_id) //delete UEs ctx std::map >::iterator ues_in_enb = m_enb_id_to_ue_ids.find(enb_id); std::set::iterator ue_id = ues_in_enb->second.begin(); - while(ue_id != ues_in_enb->second.end() ) + if(ue_id == ues_in_enb.end()) { - std::map::iterator ue_ctx = m_mme_ue_s1ap_id_to_ue_ctx.find(*ue_id); - ue_emm_ctx_t *emm_ctx = &ue_ctx->second->emm_ctx; - ue_ecm_ctx_t *ecm_ctx = &ue_ctx->second->ecm_ctx; - - m_s1ap_log->info("Releasing UE context. IMSI: %015lu, UE-MME S1AP Id: %d\n", emm_ctx->imsi, ecm_ctx->mme_ue_s1ap_id); - if(emm_ctx->state == EMM_STATE_REGISTERED) + m_s1ap_log->console("No UEs to be released\n"); + } else{ + while(ue_id != ues_in_enb->second.end() ) { - m_mme_gtpc->send_delete_session_request(emm_ctx->imsi); - emm_ctx->state = EMM_STATE_DEREGISTERED; + std::map::iterator ue_ctx = m_mme_ue_s1ap_id_to_ue_ctx.find(*ue_id); + ue_emm_ctx_t *emm_ctx = &ue_ctx->second->emm_ctx; + ue_ecm_ctx_t *ecm_ctx = &ue_ctx->second->ecm_ctx; + + m_s1ap_log->info("Releasing UE context. IMSI: %015lu, UE-MME S1AP Id: %d\n", emm_ctx->imsi, ecm_ctx->mme_ue_s1ap_id); + if(emm_ctx->state == EMM_STATE_REGISTERED) + { + m_mme_gtpc->send_delete_session_request(emm_ctx->imsi); + emm_ctx->state = EMM_STATE_DEREGISTERED; + } + m_s1ap_log->console("Releasing UE ECM context. UE-MME S1AP Id: %d\n", ecm_ctx->mme_ue_s1ap_id); + ues_in_enb->second.erase(ecm_ctx->mme_ue_s1ap_id); + ecm_ctx->state = ECM_STATE_IDLE; + ecm_ctx->mme_ue_s1ap_id = 0; + ecm_ctx->enb_ue_s1ap_id = 0; } - m_s1ap_log->console("Releasing UE ECM context. UE-MME S1AP Id: %d\n", ecm_ctx->mme_ue_s1ap_id); - ues_in_enb->second.erase(ecm_ctx->mme_ue_s1ap_id); - ecm_ctx->state = ECM_STATE_IDLE; - ecm_ctx->mme_ue_s1ap_id = 0; - ecm_ctx->enb_ue_s1ap_id = 0; } }