Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-RAN
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
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
zzha zzha
OpenXG-RAN
Commits
f2f0e68f
Commit
f2f0e68f
authored
Jan 05, 2016
by
Navid Nikaein
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the bug in the RB tree, and sanity test for the timer API
parent
f7d591f1
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
233 additions
and
117 deletions
+233
-117
common/utils/collection/tree.h
common/utils/collection/tree.h
+177
-54
common/utils/itti/timer.c
common/utils/itti/timer.c
+1
-7
openair2/ENB_APP/enb_agent.c
openair2/ENB_APP/enb_agent.c
+4
-1
openair2/ENB_APP/enb_agent_common.c
openair2/ENB_APP/enb_agent_common.c
+40
-47
openair2/ENB_APP/enb_agent_common.h
openair2/ENB_APP/enb_agent_common.h
+6
-3
openair2/ENB_APP/enb_agent_handler.c
openair2/ENB_APP/enb_agent_handler.c
+5
-5
No files found.
common/utils/collection/tree.h
View file @
f2f0e68f
This diff is collapsed.
Click to expand it.
common/utils/itti/timer.c
View file @
f2f0e68f
...
@@ -95,8 +95,7 @@ int timer_handle_signal(siginfo_t *info)
...
@@ -95,8 +95,7 @@ int timer_handle_signal(siginfo_t *info)
// LG: To many traces for msc timer:
// LG: To many traces for msc timer:
TMR_DEBUG
(
"Timer with id 0x%lx has expired
\n
"
,
(
long
)
timer_p
->
timer
);
TMR_DEBUG
(
"Timer with id 0x%lx has expired
\n
"
,
(
long
)
timer_p
->
timer
);
printf
(
"Timer with id 0x%lx has expired
\n
"
,
(
long
)
timer_p
->
timer
);
task_id
=
timer_p
->
task_id
;
task_id
=
timer_p
->
task_id
;
instance
=
timer_p
->
instance
;
instance
=
timer_p
->
instance
;
message_p
=
itti_alloc_new_message
(
TASK_TIMER
,
TIMER_HAS_EXPIRED
);
message_p
=
itti_alloc_new_message
(
TASK_TIMER
,
TIMER_HAS_EXPIRED
);
...
@@ -210,11 +209,6 @@ int timer_setup(
...
@@ -210,11 +209,6 @@ int timer_setup(
type
==
TIMER_PERIODIC
?
"periodic"
:
"single shot"
,
type
==
TIMER_PERIODIC
?
"periodic"
:
"single shot"
,
*
timer_id
,
interval_sec
,
interval_us
);
*
timer_id
,
interval_sec
,
interval_us
);
printf
(
"Requesting new %s timer with id 0x%lx that expires within "
"%d sec and %d usec
\n
"
,
type
==
TIMER_PERIODIC
?
"periodic"
:
"single shot"
,
*
timer_id
,
interval_sec
,
interval_us
);
timer_p
->
timer
=
timer
;
timer_p
->
timer
=
timer
;
/* Lock the queue and insert the timer at the tail */
/* Lock the queue and insert the timer at the tail */
...
...
openair2/ENB_APP/enb_agent.c
View file @
f2f0e68f
...
@@ -40,6 +40,7 @@
...
@@ -40,6 +40,7 @@
#include "assertions.h"
#include "assertions.h"
//#define TEST_TIMER
enb_agent_instance_t
enb_agent
[
NUM_MAX_ENB_AGENT
];
enb_agent_instance_t
enb_agent
[
NUM_MAX_ENB_AGENT
];
msg_context_t
shared_ctxt
[
NUM_MAX_ENB_AGENT
];
msg_context_t
shared_ctxt
[
NUM_MAX_ENB_AGENT
];
...
@@ -327,8 +328,10 @@ int enb_agent_stop(mid_t mod_id){
...
@@ -327,8 +328,10 @@ int enb_agent_stop(mid_t mod_id){
err_code_t
enb_agent_timeout
(
void
*
args
){
err_code_t
enb_agent_timeout
(
void
*
args
){
// enb_agent_timer_args_t *timer_args = calloc(1, sizeof(*timer_args));
//memcpy (timer_args, args, sizeof(*timer_args));
enb_agent_timer_args_t
*
timer_args
=
(
enb_agent_timer_args_t
*
)
args
;
enb_agent_timer_args_t
*
timer_args
=
(
enb_agent_timer_args_t
*
)
args
;
LOG_I
(
ENB_AGENT
,
"enb_agent %d timeout
\n
"
,
timer_args
->
mod_id
);
LOG_I
(
ENB_AGENT
,
"enb_agent %d timeout
\n
"
,
timer_args
->
mod_id
);
LOG_I
(
ENB_AGENT
,
"eNB action %d ENB flags %d
\n
"
,
timer_args
->
cc_actions
,
timer_args
->
cc_report_flags
);
LOG_I
(
ENB_AGENT
,
"eNB action %d ENB flags %d
\n
"
,
timer_args
->
cc_actions
,
timer_args
->
cc_report_flags
);
LOG_I
(
ENB_AGENT
,
"UE action %d UE flags %d
\n
"
,
timer_args
->
ue_actions
,
timer_args
->
ue_report_flags
);
LOG_I
(
ENB_AGENT
,
"UE action %d UE flags %d
\n
"
,
timer_args
->
ue_actions
,
timer_args
->
ue_report_flags
);
...
...
openair2/ENB_APP/enb_agent_common.c
View file @
f2f0e68f
...
@@ -312,25 +312,12 @@ int get_ue_wcqi (mid_t mod_id, mid_t ue_id) {
...
@@ -312,25 +312,12 @@ int get_ue_wcqi (mid_t mod_id, mid_t ue_id) {
//struct enb_agent_map agent_map;
//struct enb_agent_map agent_map;
enb_agent_timer_instance_t
timer_instance
;
/* The timer_id might not be the best choice for the comparison */
int
enb_agent_compare_timer
(
struct
enb_agent_timer_element_s
*
a
,
struct
enb_agent_timer_element_s
*
b
){
//if (a->timer_id) return 0;
//if (b->timer_id) return 0;
if
(
a
->
timer_id
<
b
->
timer_id
)
return
-
1
;
if
(
a
->
timer_id
>
b
->
timer_id
)
return
1
;
// equal timers
return
0
;
}
RB_GENERATE
(
enb_agent_map
,
enb_agent_timer_element_s
,
entry
,
enb_agent_compare_timer
);
err_code_t
enb_agent_init_timer
(
void
){
err_code_t
enb_agent_init_timer
(
void
){
LOG_I
(
ENB_AGENT
,
"init RB tree
\n
"
);
RB_INIT
(
&
enb_agent_head
);
RB_INIT
(
&
timer_instance
.
enb_agent_head
);
/*
/*
struct enb_agent_timer_element_s e;
struct enb_agent_timer_element_s e;
...
@@ -340,6 +327,18 @@ err_code_t enb_agent_init_timer(void){
...
@@ -340,6 +327,18 @@ err_code_t enb_agent_init_timer(void){
return
PROTOCOL__PROGRAN_ERR__NO_ERR
;
return
PROTOCOL__PROGRAN_ERR__NO_ERR
;
}
}
RB_GENERATE
(
enb_agent_map
,
enb_agent_timer_element_s
,
entry
,
enb_agent_compare_timer
);
/* The timer_id might not be the best choice for the comparison */
int
enb_agent_compare_timer
(
struct
enb_agent_timer_element_s
*
a
,
struct
enb_agent_timer_element_s
*
b
){
if
(
a
->
timer_id
<
b
->
timer_id
)
return
-
1
;
if
(
a
->
timer_id
>
b
->
timer_id
)
return
1
;
// equal timers
return
0
;
}
err_code_t
enb_agent_create_timer
(
uint32_t
interval_sec
,
err_code_t
enb_agent_create_timer
(
uint32_t
interval_sec
,
uint32_t
interval_usec
,
uint32_t
interval_usec
,
agent_id_t
agent_id
,
agent_id_t
agent_id
,
...
@@ -349,7 +348,9 @@ err_code_t enb_agent_create_timer(uint32_t interval_sec,
...
@@ -349,7 +348,9 @@ err_code_t enb_agent_create_timer(uint32_t interval_sec,
void
*
timer_args
,
void
*
timer_args
,
long
*
timer_id
){
long
*
timer_id
){
struct
enb_agent_timer_element_s
e
;
struct
enb_agent_timer_element_s
*
e
=
calloc
(
1
,
sizeof
(
*
e
));
DevAssert
(
e
!=
NULL
);
//uint32_t timer_id;
//uint32_t timer_id;
int
ret
=-
1
;
int
ret
=-
1
;
...
@@ -368,7 +369,7 @@ err_code_t enb_agent_create_timer(uint32_t interval_sec,
...
@@ -368,7 +369,7 @@ err_code_t enb_agent_create_timer(uint32_t interval_sec,
timer_args
,
timer_args
,
timer_id
);
timer_id
);
e
.
type
=
TIMER_ONE_SHOT
;
e
->
type
=
TIMER_ONE_SHOT
;
}
}
else
if
(
timer_type
==
ENB_AGENT_TIMER_TYPE_PERIODIC
){
else
if
(
timer_type
==
ENB_AGENT_TIMER_TYPE_PERIODIC
){
ret
=
timer_setup
(
interval_sec
,
ret
=
timer_setup
(
interval_sec
,
...
@@ -379,32 +380,25 @@ err_code_t enb_agent_create_timer(uint32_t interval_sec,
...
@@ -379,32 +380,25 @@ err_code_t enb_agent_create_timer(uint32_t interval_sec,
timer_args
,
timer_args
,
timer_id
);
timer_id
);
e
.
type
=
TIMER_PERIODIC
;
e
->
type
=
TIMER_PERIODIC
;
}
}
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
return
TIMER_SETUP_FAILED
;
return
TIMER_SETUP_FAILED
;
}
}
e
.
agent_id
=
agent_id
;
e
->
agent_id
=
agent_id
;
e
.
instance
=
instance
;
e
->
instance
=
instance
;
e
.
state
=
ENB_AGENT_TIMER_STATE_ACTIVE
;
e
->
state
=
ENB_AGENT_TIMER_STATE_ACTIVE
;
e
.
timer_id
=
*
timer_id
;
e
->
timer_id
=
*
timer_id
;
e
.
timer_args
=
timer_args
;
// e->timer_args = timer_args;
e
.
cb
=
cb
;
e
->
cb
=
cb
;
/*element should be a real pointer*/
LOG_I
(
ENB_AGENT
,
"created a timer with id 0x%lx for agent %d, instance %d
\n
"
,
RB_INSERT
(
enb_agent_map
,
&
timer_instance
.
enb_agent_head
,
e
);
e
.
timer_id
,
e
.
agent_id
,
e
.
instance
);
LOG_I
(
ENB_AGENT
,
"Created a new timer with id 0x%lx for agent %d, instance %d
\n
"
,
RB_INSERT
(
enb_agent_map
,
&
enb_agent_head
,
&
e
);
e
->
timer_id
,
e
->
agent_id
,
e
->
instance
);
/*
struct enb_agent_timer_element_s search;
search.timer_id = *timer_id;
printf("search 1: %p (expected %p)\n", RB_FIND(enb_agent_map, &enb_agent_head, &search), &e);
printf("search 1: %p (expected %p)\n", get_timer_entry(e.timer_id), &e);
*/
return
0
;
return
0
;
}
}
...
@@ -413,7 +407,7 @@ err_code_t enb_agent_destroy_timer(long timer_id){
...
@@ -413,7 +407,7 @@ err_code_t enb_agent_destroy_timer(long timer_id){
struct
enb_agent_timer_element_s
*
e
=
get_timer_entry
(
timer_id
);
struct
enb_agent_timer_element_s
*
e
=
get_timer_entry
(
timer_id
);
if
(
e
!=
NULL
)
{
if
(
e
!=
NULL
)
{
RB_REMOVE
(
enb_agent_map
,
&
enb_agent_head
,
&
e
);
RB_REMOVE
(
enb_agent_map
,
&
timer_instance
.
enb_agent_head
,
&
e
);
free
(
e
);
free
(
e
);
}
}
...
@@ -431,8 +425,8 @@ err_code_t enb_agent_destroy_timers(void){
...
@@ -431,8 +425,8 @@ err_code_t enb_agent_destroy_timers(void){
struct
enb_agent_timer_element_s
*
e
=
NULL
;
struct
enb_agent_timer_element_s
*
e
=
NULL
;
RB_FOREACH
(
e
,
enb_agent_map
,
&
enb_agent_head
)
{
RB_FOREACH
(
e
,
enb_agent_map
,
&
timer_instance
.
enb_agent_head
)
{
RB_REMOVE
(
enb_agent_map
,
&
enb_agent_head
,
e
);
RB_REMOVE
(
enb_agent_map
,
&
timer_instance
.
enb_agent_head
,
e
);
timer_remove
(
e
->
timer_id
);
timer_remove
(
e
->
timer_id
);
free
(
e
);
free
(
e
);
}
}
...
@@ -443,11 +437,10 @@ err_code_t enb_agent_destroy_timers(void){
...
@@ -443,11 +437,10 @@ err_code_t enb_agent_destroy_timers(void){
struct
enb_agent_timer_element_s
*
get_timer_entry
(
long
timer_id
)
{
struct
enb_agent_timer_element_s
*
get_timer_entry
(
long
timer_id
)
{
struct
enb_agent_timer_element_s
search
,
*
e
;
struct
enb_agent_timer_element_s
*
search
=
calloc
(
1
,
sizeof
(
*
search
));
memset
(
&
search
,
0
,
sizeof
(
struct
enb_agent_timer_element_s
));
search
->
timer_id
=
timer_id
;
search
.
timer_id
=
timer_id
;
return
RB_FIND
(
enb_agent_map
,
&
timer_instance
.
enb_agent_head
,
search
);
return
RB_FIND
(
enb_agent_map
,
&
enb_agent_head
,
&
search
);
}
}
/*
/*
...
...
openair2/ENB_APP/enb_agent_common.h
View file @
f2f0e68f
...
@@ -189,10 +189,13 @@ typedef struct enb_agent_timer_element_s{
...
@@ -189,10 +189,13 @@ typedef struct enb_agent_timer_element_s{
long
timer_id
;
/* Timer id returned by the timer API*/
long
timer_id
;
/* Timer id returned by the timer API*/
enb_agent_timer_callback_t
cb
;
enb_agent_timer_callback_t
cb
;
void
*
timer_args
;
//
void* timer_args;
}
enb_agent_timer_element_t
;
}
enb_agent_timer_element_t
;
typedef
struct
enb_agent_timer_instance_s
{
RB_HEAD
(
enb_agent_map
,
enb_agent_timer_element_s
)
enb_agent_head
;
}
enb_agent_timer_instance_t
;
err_code_t
enb_agent_init_timer
(
void
);
err_code_t
enb_agent_init_timer
(
void
);
...
@@ -214,11 +217,11 @@ err_code_t enb_agent_restart_timer(long *timer_id);
...
@@ -214,11 +217,11 @@ err_code_t enb_agent_restart_timer(long *timer_id);
struct
enb_agent_timer_element_s
*
get_timer_entry
(
long
timer_id
);
struct
enb_agent_timer_element_s
*
get_timer_entry
(
long
timer_id
);
int
enb_agent_compare_timer
(
struct
enb_agent_timer_element_s
*
a
,
struct
enb_agent_timer_element_s
*
b
);
err_code_t
enb_agent_process_timeout
(
long
timer_id
,
void
*
timer_args
);
err_code_t
enb_agent_process_timeout
(
long
timer_id
,
void
*
timer_args
);
RB_HEAD
(
enb_agent_map
,
enb_agent_timer_element_s
)
enb_agent_head
;
int
enb_agent_compare_timer
(
struct
enb_agent_timer_element_s
*
a
,
struct
enb_agent_timer_element_s
*
b
)
;
/* RB_PROTOTYPE is for .h files */
/* RB_PROTOTYPE is for .h files */
RB_PROTOTYPE
(
enb_agent_map
,
enb_agent_timer_element_s
,
entry
,
enb_agent_compare_timer
);
RB_PROTOTYPE
(
enb_agent_map
,
enb_agent_timer_element_s
,
entry
,
enb_agent_compare_timer
);
...
...
openair2/ENB_APP/enb_agent_handler.c
View file @
f2f0e68f
...
@@ -141,15 +141,15 @@ void * enb_agent_send_message(xid_t xid,
...
@@ -141,15 +141,15 @@ void * enb_agent_send_message(xid_t xid,
err_code_t
enb_agent_process_timeout
(
long
timer_id
,
void
*
timer_args
){
err_code_t
enb_agent_process_timeout
(
long
timer_id
,
void
*
timer_args
){
struct
enb_agent_timer_element_s
*
e
=
get_timer_entry
(
timer_id
);
struct
enb_agent_timer_element_s
*
found
=
get_timer_entry
(
timer_id
);
if
(
found
==
NULL
)
goto
error
;
LOG_I
(
ENB_AGENT
,
"Found the entry (%p): timer_id is 0x%lx 0x%lx
\n
"
,
found
,
timer_id
,
found
->
timer_id
);
LOG_I
(
ENB_AGENT
,
"element %p: timer_id is 0x%lx 0x%lx
\n
"
,
e
,
timer_id
,
e
->
timer_id
);
if
(
e
==
NULL
)
goto
error
;
if
(
timer_args
==
NULL
)
if
(
timer_args
==
NULL
)
LOG_W
(
ENB_AGENT
,
"null timer args
\n
"
);
LOG_W
(
ENB_AGENT
,
"null timer args
\n
"
);
return
e
->
cb
(
timer_args
);
return
found
->
cb
(
timer_args
);
error:
error:
...
...
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