- Fixed a leak in mme_gtpc where the singleton instance was not freed.

- Rewritten the class to be self manage its lifetime.
master
faluco 4 years ago committed by faluco
parent b5b726ed48
commit 8d1705d6c6

@ -42,8 +42,9 @@ public:
srslte::gtp_fteid_t sgw_ctr_fteid; srslte::gtp_fteid_t sgw_ctr_fteid;
} gtpc_ctx_t; } gtpc_ctx_t;
static mme_gtpc* get_instance(void); virtual ~mme_gtpc() = default;
static void cleanup(void);
static mme_gtpc* get_instance();
bool init(srslte::log_filter* mme_gtpc_log); bool init(srslte::log_filter* mme_gtpc_log);
bool send_s11_pdu(const srslte::gtpc_pdu& pdu); bool send_s11_pdu(const srslte::gtpc_pdu& pdu);
@ -62,9 +63,7 @@ public:
int get_s11(); int get_s11();
private: private:
mme_gtpc(); mme_gtpc() = default;
virtual ~mme_gtpc();
static mme_gtpc* m_instance;
srslte::log_filter* m_mme_gtpc_log; srslte::log_filter* m_mme_gtpc_log;
s1ap* m_s1ap; s1ap* m_s1ap;

@ -27,42 +27,14 @@
namespace srsepc { namespace srsepc {
mme_gtpc* mme_gtpc::m_instance = NULL; mme_gtpc* mme_gtpc::get_instance()
pthread_mutex_t mme_gtpc_instance_mutex = PTHREAD_MUTEX_INITIALIZER;
mme_gtpc::mme_gtpc()
{
return;
}
mme_gtpc::~mme_gtpc()
{ {
return; static std::unique_ptr<mme_gtpc> instance = std::unique_ptr<mme_gtpc>(new mme_gtpc);
} return instance.get();
mme_gtpc* mme_gtpc::get_instance(void)
{
pthread_mutex_lock(&mme_gtpc_instance_mutex);
if (NULL == m_instance) {
m_instance = new mme_gtpc();
}
pthread_mutex_unlock(&mme_gtpc_instance_mutex);
return (m_instance);
}
void mme_gtpc::cleanup(void)
{
pthread_mutex_lock(&mme_gtpc_instance_mutex);
if (NULL != m_instance) {
delete m_instance;
m_instance = NULL;
}
pthread_mutex_unlock(&mme_gtpc_instance_mutex);
} }
bool mme_gtpc::init(srslte::log_filter* mme_gtpc_log) bool mme_gtpc::init(srslte::log_filter* mme_gtpc_log)
{ {
/*Init log*/ /*Init log*/
m_mme_gtpc_log = mme_gtpc_log; m_mme_gtpc_log = mme_gtpc_log;

Loading…
Cancel
Save