From a8f268c55b76242659b0d6f6e34e2a944fe7fbb8 Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Sun, 17 Dec 2017 16:30:50 +0000 Subject: [PATCH] Added cleanup functionality to the hss. --- srsepc/hdr/hss/hss.h | 2 ++ srsepc/src/hss/hss.cc | 23 +++++++++++++++++++---- srsepc/src/main.cc | 2 ++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/srsepc/hdr/hss/hss.h b/srsepc/hdr/hss/hss.h index 5278c99bc..4074aeb9a 100644 --- a/srsepc/hdr/hss/hss.h +++ b/srsepc/hdr/hss/hss.h @@ -67,6 +67,8 @@ public: static hss* get_instance(void); static void cleanup(void); int init(hss_args_t *hss_args, srslte::log_filter* hss_log); + void stop(void); + bool set_auth_algo(std::string auth_algo); bool read_db_file(std::string db_file); diff --git a/srsepc/src/hss/hss.cc b/srsepc/src/hss/hss.cc index e8cbf52ae..659933c7b 100644 --- a/srsepc/src/hss/hss.cc +++ b/srsepc/src/hss/hss.cc @@ -48,10 +48,6 @@ hss::hss() hss::~hss() { - if(m_db_file.is_open()) - { - m_db_file.close(); - } return; } @@ -98,6 +94,25 @@ hss::init(hss_args_t *hss_args, srslte::log_filter *hss_log) return 0; } +void +hss::stop(void) +{ + std::map::iterator it = m_imsi_to_ue_ctx.begin(); + while(it!=m_imsi_to_ue_ctx.end()) + { + m_hss_log->info("Deleting UE context in HSS. IMSI: %lu\n", it->second->imsi); + m_hss_log->console("Deleting UE context in HSS. IMSI: %lu\n", it->second->imsi); + delete it->second; + m_imsi_to_ue_ctx.erase(it++); + } + if(m_db_file.is_open()) + { + m_db_file.close(); + } + return; +} + + bool hss::set_auth_algo(std::string auth_algo) { diff --git a/srsepc/src/main.cc b/srsepc/src/main.cc index b579464cb..7b6ec7025 100644 --- a/srsepc/src/main.cc +++ b/srsepc/src/main.cc @@ -250,6 +250,8 @@ main (int argc,char * argv[] ) mme->cleanup(); spgw->stop(); spgw->cleanup(); + hss->stop(); + hss->cleanup(); cout << std::endl <<"--- exiting ---" << endl; return 0;