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

@ -27,42 +27,14 @@
namespace srsepc {
mme_gtpc* mme_gtpc::m_instance = NULL;
pthread_mutex_t mme_gtpc_instance_mutex = PTHREAD_MUTEX_INITIALIZER;
mme_gtpc::mme_gtpc()
{
return;
}
mme_gtpc::~mme_gtpc()
mme_gtpc* mme_gtpc::get_instance()
{
return;
}
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);
static std::unique_ptr<mme_gtpc> instance = std::unique_ptr<mme_gtpc>(new mme_gtpc);
return instance.get();
}
bool mme_gtpc::init(srslte::log_filter* mme_gtpc_log)
{
/*Init log*/
m_mme_gtpc_log = mme_gtpc_log;

Loading…
Cancel
Save