Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
belle-sip
Commits
e2e516dc
Commit
e2e516dc
authored
Jun 14, 2016
by
Simon Morlat
Browse files
fix main loop reentrancy problem resulting in liblinphone possibly blocking for a long time
parent
d3f485b3
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/belle_sip_loop.c
View file @
e2e516dc
...
...
@@ -249,7 +249,7 @@ struct belle_sip_main_loop{
belle_sip_object_pool_t
*
pool
;
int
nsources
;
int
run
;
int
in_
iterate
;
int
in_
loop
;
};
void
belle_sip_main_loop_remove_source
(
belle_sip_main_loop_t
*
ml
,
belle_sip_source_t
*
source
){
...
...
@@ -360,7 +360,7 @@ void belle_sip_main_loop_cancel_source(belle_sip_main_loop_t *ml, unsigned long
belle_sip_source_cancel
(
s
);
}
void
belle_sip_main_loop_iterate
(
belle_sip_main_loop_t
*
ml
){
static
void
belle_sip_main_loop_iterate
(
belle_sip_main_loop_t
*
ml
){
size_t
pfd_size
=
ml
->
nsources
*
sizeof
(
belle_sip_pollfd_t
);
belle_sip_pollfd_t
*
pfd
=
(
belle_sip_pollfd_t
*
)
belle_sip_malloc0
(
pfd_size
);
int
i
=
0
;
...
...
@@ -374,12 +374,6 @@ void belle_sip_main_loop_iterate(belle_sip_main_loop_t *ml){
int
can_clean
=
belle_sip_object_pool_cleanable
(
ml
->
pool
);
/*iterate might not be called by the thread that created the main loop*/
belle_sip_object_pool_t
*
tmp_pool
=
NULL
;
if
(
ml
->
in_iterate
){
belle_sip_warning
(
"belle_sip_main_loop_iterate([%p]): reentrancy detected, doing nothing."
,
ml
);
return
;
}
ml
->
in_iterate
=
TRUE
;
if
(
!
can_clean
){
/*Push a temporary pool for the time of the iterate loop*/
tmp_pool
=
belle_sip_object_pool_push
();
...
...
@@ -479,16 +473,19 @@ void belle_sip_main_loop_iterate(belle_sip_main_loop_t *ml){
else
if
(
tmp_pool
)
belle_sip_object_unref
(
tmp_pool
);
end:
belle_sip_free
(
pfd
);
ml
->
in_iterate
=
FALSE
;
}
void
belle_sip_main_loop_run
(
belle_sip_main_loop_t
*
ml
){
ml
->
run
=
1
;
if
(
ml
->
in_loop
){
belle_sip_warning
(
"belle_sip_main_loop_run(): reentrancy detected, doing nothing"
);
return
;
}
ml
->
run
=
TRUE
;
ml
->
in_loop
=
TRUE
;
while
(
ml
->
run
){
belle_sip_main_loop_iterate
(
ml
);
if
(
ml
->
in_iterate
)
break
;
}
ml
->
in_loop
=
FALSE
;
}
int
belle_sip_main_loop_quit
(
belle_sip_main_loop_t
*
ml
){
...
...
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