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
f3d2068d
Commit
f3d2068d
authored
Jan 08, 2021
by
Tien-Thinh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid Boost connection issue
parent
b84a4bbe
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
27 deletions
+34
-27
src/nrf_app/nrf_app.cpp
src/nrf_app/nrf_app.cpp
+16
-12
src/nrf_app/nrf_profile.cpp
src/nrf_app/nrf_profile.cpp
+18
-15
No files found.
src/nrf_app/nrf_app.cpp
View file @
f3d2068d
...
...
@@ -29,6 +29,7 @@
#include "nrf_app.hpp"
#include <unistd.h>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
...
...
@@ -140,7 +141,7 @@ void nrf_app::handle_register_nf_instance(
uint64_t
ms
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
std
::
chrono
::
system_clock
::
now
().
time_since_epoch
())
.
count
();
//
sn.get()->subscribe_heartbeat_timeout_nfregistration(ms);
sn
.
get
()
->
subscribe_heartbeat_timeout_nfregistration
(
ms
);
// Notify NF status change event
m_event_sub
.
nf_status_registered
(
nf_instance_id
);
// from nrf_app
...
...
@@ -242,19 +243,22 @@ void nrf_app::handle_update_nf_instance(
std
::
chrono
::
system_clock
::
now
().
time_since_epoch
())
.
count
();
Logger
::
nrf_app
().
debug
(
"Received a NF update %ld, %d"
,
ms
,
ms
%
(
HEART_BEAT_TIMER
*
1000
));
Logger
::
nrf_app
().
debug
(
"Received a NF update %ld"
,
ms
);
// If this happens before the first Heartbeattimer expires -> remove this
// timer
/* if (sn.get()->unsubscribe_heartbeat_timeout_nfregistration()) {
// Heartbeart management for this NF profile
// get current time
if
(
sn
.
get
()
->
unsubscribe_heartbeat_timeout_nfregistration
())
{
// Sleep 100ms to avoid Boost connection related issue
unsigned
int
microsecond
=
100000
;
// 100ms
usleep
(
microsecond
);
ms
=
std
::
chrono
::
duration_cast
<
std
::
chrono
::
milliseconds
>
(
std
::
chrono
::
system_clock
::
now
().
time_since_epoch
())
.
count
();
Logger
::
nrf_app
().
debug
(
"Subscribe to HBT (NF update), current time %ld"
,
ms
);
sn
.
get
()
->
subscribe_heartbeat_timeout_nfupdate
(
ms
);
}
*/
sn
.
get
()
->
subscribe_heartbeat_timeout_nfupdate
(
ms
);
//
sn.get()->subscribe_heartbeat_timeout_nfupdate(ms);
// update NF updated flag
sn
.
get
()
->
set_status_updated
(
true
);
}
...
...
src/nrf_app/nrf_profile.cpp
View file @
f3d2068d
...
...
@@ -75,6 +75,7 @@ void nrf_profile::set_nf_type(const nf_type_t &type) { nf_type = type; }
nf_type_t
nrf_profile
::
get_nf_type
()
const
{
return
nf_type
;
}
//------------------------------------------------------------------------------
void
nrf_profile
::
set_nf_status
(
const
std
::
string
&
status
)
{
std
::
unique_lock
lock
(
heartbeart_mutex
);
nf_status
=
status
;
}
...
...
@@ -426,23 +427,22 @@ void nrf_profile::to_json(nlohmann::json &data) const {
//------------------------------------------------------------------------------
void
nrf_profile
::
subscribe_heartbeat_timeout_nfregistration
(
uint64_t
ms
)
{
// For the first timeout, we use 2*HEART_BEAT_TIMER as interval
struct
itimerspec
its
;
its
.
it_value
.
tv_sec
=
HEART_BEAT_TIMER
;
// seconds
its
.
it_value
.
tv_sec
=
2
*
HEART_BEAT_TIMER
;
// seconds
its
.
it_value
.
tv_nsec
=
0
;
// 100 * 1000 * 1000; //100ms
const
uint64_t
interval
=
its
.
it_value
.
tv_sec
*
1000
+
its
.
it_value
.
tv_nsec
/
1000000
;
// convert sec, nsec to msec
// TODO: remove hardcoded 2*HEART_BEAT_TIMER
Logger
::
nrf_app
().
debug
(
"Subscribe to t
ask tick to be noticed when the first Heartbearttimer
"
"
(%d) expires (after NF registration) %ld, %
d"
,
2
*
HEART_BEAT_TIMER
,
ms
,
ms
%
(
HEART_BEAT_TIMER
*
1000
)
);
"Subscribe to t
he HeartBeartTimer expire event (after NF
"
"
registration): interval %d, current time %l
d"
,
2
*
HEART_BEAT_TIMER
,
ms
);
first_hb_connection
=
m_event_sub
.
subscribe_task_tick
(
boost
::
bind
(
&
nrf_profile
::
handle_heartbeart_timeout_nfregistration
,
this
,
_1
),
interval
,
(
HEART_BEAT_TIMER
*
1000
*
2
+
ms
%
(
HEART_BEAT_TIMER
*
1000
))
/* start at time 0 */
);
interval
,
ms
+
interval
);
}
//------------------------------------------------------------------------------
...
...
@@ -455,9 +455,9 @@ void nrf_profile::subscribe_heartbeat_timeout_nfupdate(uint64_t ms) {
its
.
it_value
.
tv_nsec
/
1000000
;
// convert sec, nsec to msec
Logger
::
nrf_app
().
debug
(
"Subscribe to
task tick to be noticed when the Heartbearttimer (%d)
"
"
expires (after NF update) %ld, %
d"
,
HEART_BEAT_TIMER
,
ms
,
ms
%
(
HEART_BEAT_TIMER
*
1000
)
);
"Subscribe to
HeartbeatTimer expire event (after NF update): interval
"
"
%d, current time %l
d"
,
HEART_BEAT_TIMER
,
ms
);
if
(
!
first_update
)
{
ms
=
ms
+
2000
;
// Not a realtime NF: adding 2000ms interval between the
...
...
@@ -473,7 +473,8 @@ void nrf_profile::subscribe_heartbeat_timeout_nfupdate(uint64_t ms) {
bool
nrf_profile
::
unsubscribe_heartbeat_timeout_nfupdate
()
{
if
(
task_connection
.
connected
())
{
task_connection
.
disconnect
();
Logger
::
nrf_app
().
debug
(
"Unsubscribe to the Heartbeat Timer timeout event"
);
Logger
::
nrf_app
().
debug
(
"Unsubscribe to the Heartbeat Timer timeout event (after NF Update)"
);
return
true
;
}
else
{
return
false
;
...
...
@@ -485,7 +486,8 @@ bool nrf_profile::unsubscribe_heartbeat_timeout_nfregistration() {
if
(
first_hb_connection
.
connected
())
{
first_hb_connection
.
disconnect
();
Logger
::
nrf_app
().
debug
(
"Unsubscribe to the first Heartbeat Timer timeout event"
);
"Unsubscribe to the first Heartbeat Timer timeout event (after NF "
"Registration)"
);
return
true
;
}
else
{
return
false
;
...
...
@@ -502,8 +504,9 @@ void nrf_profile::handle_heartbeart_timeout(uint64_t ms) {
//------------------------------------------------------------------------------
void
nrf_profile
::
handle_heartbeart_timeout_nfregistration
(
uint64_t
ms
)
{
Logger
::
nrf_app
().
info
(
"
\n
Handle the first
heartbeart timeout profile %s,
time %d"
,
"
\n
Handle the first
Heartbeat timeout NF instance id %s, current
time %d"
,
nf_instance_id
.
c_str
(),
ms
);
// Set status to SUSPENDED and unsubscribe to the HBT
set_nf_status
(
"SUSPENDED"
);
unsubscribe_heartbeat_timeout_nfregistration
();
}
...
...
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