Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-NRF
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenXG
OpenXG-NRF
Commits
772db6b7
Commit
772db6b7
authored
Dec 19, 2020
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deconstruction/memory leak
parent
e524ce7b
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
44 additions
and
46 deletions
+44
-46
src/common/dynamic_memory_check.c
src/common/dynamic_memory_check.c
+0
-8
src/common/dynamic_memory_check.h
src/common/dynamic_memory_check.h
+0
-2
src/common/utils/mime_parser.cpp
src/common/utils/mime_parser.cpp
+6
-3
src/nrf_app/nrf_app.cpp
src/nrf_app/nrf_app.cpp
+10
-6
src/nrf_app/nrf_app.hpp
src/nrf_app/nrf_app.hpp
+9
-1
src/nrf_app/nrf_event.cpp
src/nrf_app/nrf_event.cpp
+15
-22
src/nrf_app/nrf_profile.hpp
src/nrf_app/nrf_profile.hpp
+2
-2
src/nrf_app/nrf_subscription.hpp
src/nrf_app/nrf_subscription.hpp
+2
-2
No files found.
src/common/dynamic_memory_check.c
View file @
772db6b7
...
...
@@ -41,11 +41,3 @@ void free_wrapper(void **ptr) {
}
}
//------------------------------------------------------------------------------
void
bdestroy_wrapper
(
bstring
*
b
)
{
if
((
b
)
&&
(
*
b
))
{
bdestroy
(
*
b
);
*
b
=
NULL
;
}
}
src/common/dynamic_memory_check.h
View file @
772db6b7
...
...
@@ -28,9 +28,7 @@
#ifndef FILE_DYNAMIC_MEMORY_CHECK_SEEN
#define FILE_DYNAMIC_MEMORY_CHECK_SEEN
# include "bstrlib.h"
void
free_wrapper
(
void
**
ptr
)
__attribute__
((
hot
));
void
bdestroy_wrapper
(
bstring
*
b
);
#endif
/* FILE_DYNAMIC_MEMORY_CHECK_SEEN */
src/common/utils/mime_parser.cpp
View file @
772db6b7
...
...
@@ -23,6 +23,11 @@
#include "logger.hpp"
#include "conversions.hpp"
extern
"C"
{
#include "dynamic_memory_check.h"
}
bool
mime_parser
::
parse
(
const
std
::
string
&
str
)
{
std
::
string
CRLF
=
"
\r\n
"
;
Logger
::
nrf_app
().
debug
(
"Parsing the message with Simple Parser"
);
...
...
@@ -91,9 +96,7 @@ unsigned char* mime_parser::format_string_as_hex(const std::string &str) {
printf
(
"
\n
"
);
#endif
//free memory
//free_wrapper((void**) &data);
free
(
data
);
data
=
NULL
;
free_wrapper
((
void
**
)
&
data
);
return
data_hex
;
}
...
...
src/nrf_app/nrf_app.cpp
View file @
772db6b7
...
...
@@ -47,7 +47,9 @@ nrf_client *nrf_client_inst = nullptr;
//------------------------------------------------------------------------------
nrf_app
::
nrf_app
(
const
std
::
string
&
config_file
,
nrf_event
&
ev
)
:
m_event_sub
(
ev
)
{
:
m_event_sub
(
ev
),
m_instance_id2nrf_profile
(),
m_instance_id2nrf_subscription
()
{
Logger
::
nrf_app
().
startup
(
"Starting..."
);
try
{
...
...
@@ -114,7 +116,7 @@ void nrf_app::handle_register_nf_instance(
add_nf_profile
(
nf_instance_id
,
sn
);
Logger
::
nrf_app
().
debug
(
"Added/Updated NF Profile to the DB"
);
//
h
eartbeart management for this NF profile
//
H
eartbeart management for this NF profile
// get current time
uint64_t
ms
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
std
::
chrono
::
system_clock
::
now
().
time_since_epoch
())
...
...
@@ -122,7 +124,6 @@ void nrf_app::handle_register_nf_instance(
sn
.
get
()
->
subscribe_task_tick
(
ms
);
// Notify NF status change event
// m_event_sub.nf_status_change(p); //from subscription
m_event_sub
.
nf_status_registered
(
nf_instance_id
);
// from nrf_app
// display the info
...
...
@@ -553,8 +554,9 @@ void nrf_app::subscribe_nf_status() {
//------------------------------------------------------------------------------
void
nrf_app
::
subscribe_nf_status_registered
()
{
Logger
::
nrf_app
().
debug
(
"Subscribe to NF status registered"
);
m_event_sub
.
subscribe_nf_status_registered
(
bs2
::
connection
c
=
m_event_sub
.
subscribe_nf_status_registered
(
boost
::
bind
(
&
nrf_app
::
handle_nf_status_registered
,
this
,
_1
));
connections
.
push_back
(
c
);
}
//------------------------------------------------------------------------------
...
...
@@ -582,8 +584,9 @@ void nrf_app::handle_nf_status_registered(const std::string &profile_id) {
//------------------------------------------------------------------------------
void
nrf_app
::
subscribe_nf_status_deregistered
()
{
Logger
::
nrf_app
().
debug
(
"Subscribe to NF status deregistered"
);
m_event_sub
.
subscribe_nf_status_deregistered
(
bs2
::
connection
c
=
m_event_sub
.
subscribe_nf_status_deregistered
(
boost
::
bind
(
&
nrf_app
::
handle_nf_status_deregistered
,
this
,
_1
));
connections
.
push_back
(
c
);
}
//------------------------------------------------------------------------------
...
...
@@ -599,8 +602,9 @@ void nrf_app::handle_nf_status_deregistered(const std::string &profile_id) {
//------------------------------------------------------------------------------
void
nrf_app
::
subscribe_nf_status_profile_changed
()
{
Logger
::
nrf_app
().
debug
(
"Subscribe to NF status profile changed"
);
m_event_sub
.
subscribe_nf_status_profile_changed
(
bs2
::
connection
c
=
m_event_sub
.
subscribe_nf_status_profile_changed
(
boost
::
bind
(
&
nrf_app
::
handle_nf_status_profile_changed
,
this
,
_1
));
connections
.
push_back
(
c
);
}
//------------------------------------------------------------------------------
...
...
src/nrf_app/nrf_app.hpp
View file @
772db6b7
...
...
@@ -53,6 +53,14 @@ class nrf_app {
nrf_app
(
nrf_app
const
&
)
=
delete
;
void
operator
=
(
nrf_app
const
&
)
=
delete
;
virtual
~
nrf_app
()
{
Logger
::
nrf_app
().
debug
(
"Delete NRF_APP instance..."
);
for
(
auto
i
:
connections
)
{
if
(
i
.
connected
())
i
.
disconnect
();
}
}
/*
* Handle a Register NF Instance request
* @param [const std::string &] nf_instance_id: Instance ID
...
...
@@ -228,9 +236,9 @@ class nrf_app {
std
::
map
<
std
::
string
,
std
::
shared_ptr
<
nrf_subscription
>>
instance_id2nrf_subscription
;
mutable
std
::
shared_mutex
m_instance_id2nrf_subscription
;
nrf_event
&
m_event_sub
;
util
::
uint_generator
<
uint32_t
>
evsub_id_generator
;
std
::
vector
<
bs2
::
connection
>
connections
;
};
}
}
...
...
src/nrf_app/nrf_event.cpp
View file @
772db6b7
...
...
@@ -3,9 +3,9 @@
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this
file
*
except in compliance with the License.
*
You may obtain a copy of the
License at
* the OAI Public License, Version 1.1 (the "License"); you may not use this
*
file except in compliance with the License. You may obtain a copy of the
* License at
*
* http://www.openairinterface.org/?page_id=698
*
...
...
@@ -28,50 +28,48 @@
*/
#include "nrf_event.hpp"
#include <iostream>
#include "nrf_app.hpp"
#include "nrf_event_sig.hpp"
#include <iostream>
using
namespace
oai
::
nrf
::
app
;
//------------------------------------------------------------------------------
bs2
::
connection
nrf_event
::
subscribe_task_tick
(
const
task_sig_t
::
slot_type
&
sig
,
uint64_t
period
,
uint64_t
start
)
{
bs2
::
connection
nrf_event
::
subscribe_task_tick
(
const
task_sig_t
::
slot_type
&
sig
,
uint64_t
period
,
uint64_t
start
)
{
/* Wrap the actual callback in a lambda. The latter checks whether the
* current time is after start time, and ensures that the callback is only
* called every X ms with X being the period time. This way, it is possible
* to register to be notified every X ms instead of every ms, which provides
* greater freedom to implementations. */
auto
f
=
[
period
,
start
,
sig
]
(
uint64_t
t
)
{
if
(
t
>=
start
&&
(
t
-
start
)
%
period
==
0
)
sig
(
t
);
};
auto
f
=
[
period
,
start
,
sig
](
uint64_t
t
)
{
if
(
t
>=
start
&&
(
t
-
start
)
%
period
==
0
)
sig
(
t
);
};
return
task_tick
.
connect
(
f
);
}
//------------------------------------------------------------------------------
bs2
::
connection
nrf_event
::
subscribe_task_tick_extended
(
const
task_sig_t
::
extended_slot_type
&
sig
,
uint64_t
period
,
uint64_t
start
)
{
const
task_sig_t
::
extended_slot_type
&
sig
,
uint64_t
period
,
uint64_t
start
)
{
/* Wrap the actual callback in a lambda. The latter checks whether the
* current time is after start time, and ensures that the callback is only
* called every X ms with X being the period time. This way, it is possible
* to register to be notified every X ms instead of every ms, which provides
* greater freedom to implementations. */
auto
f
=
[
period
,
start
,
sig
]
(
const
bs2
::
connection
&
c
,
uint64_t
t
)
{
if
(
t
>=
start
&&
(
t
-
start
)
%
period
==
0
)
sig
(
c
,
t
);
};
auto
f
=
[
period
,
start
,
sig
](
const
bs2
::
connection
&
c
,
uint64_t
t
)
{
if
(
t
>=
start
&&
(
t
-
start
)
%
period
==
0
)
sig
(
c
,
t
);
};
return
task_tick
.
connect_extended
(
f
);
}
//------------------------------------------------------------------------------
bs2
::
connection
nrf_event
::
subscribe_nf_status_change
(
const
nf_status_change_sig_t
::
slot_type
&
sig
)
{
return
nf_status_change
.
connect
(
sig
);
}
//------------------------------------------------------------------------------
bs2
::
connection
nrf_event
::
subscribe_nf_status_registered
(
const
nf_status_sig_t
::
slot_type
&
sig
)
{
...
...
@@ -89,8 +87,3 @@ bs2::connection nrf_event::subscribe_nf_status_profile_changed(
const
nf_status_sig_t
::
slot_type
&
sig
)
{
return
nf_status_profile_changed
.
connect
(
sig
);
}
src/nrf_app/nrf_profile.hpp
View file @
772db6b7
...
...
@@ -97,8 +97,8 @@ class nrf_profile : public std::enable_shared_from_this<nrf_profile> {
nrf_profile
(
nrf_profile
&
b
)
=
delete
;
virtual
~
nrf_profile
()
{
Logger
::
nrf_app
().
debug
(
"Delete instance..."
);
task_connection
.
disconnect
();
Logger
::
nrf_app
().
debug
(
"Delete
NRF Profile
instance..."
);
if
(
task_connection
.
connected
())
task_connection
.
disconnect
();
}
/*
...
...
src/nrf_app/nrf_subscription.hpp
View file @
772db6b7
...
...
@@ -48,8 +48,8 @@ class nrf_subscription {
};
nrf_subscription
(
nrf_subscription
const
&
)
=
delete
;
virtual
~
nrf_subscription
()
{
Logger
::
nrf_app
().
debug
(
"Delete instance..."
);
ev_connection
.
disconnect
();
Logger
::
nrf_app
().
debug
(
"Delete
NRF Subscription
instance..."
);
if
(
ev_connection
.
connected
())
ev_connection
.
disconnect
();
}
void
operator
=
(
nrf_subscription
const
&
)
=
delete
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment