Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
46a8800d
Commit
46a8800d
authored
10 years ago
by
Guillaume Roguez
Browse files
Options
Downloads
Patches
Plain Diff
ice: fix pjsip memory pool leak
Refs #62797 Change-Id: Ie5f0c21720191f9420109bf0ff7fd834348d5195
parent
4c906b26
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
daemon/src/ice_transport.cpp
+26
-21
26 additions, 21 deletions
daemon/src/ice_transport.cpp
daemon/src/ice_transport.h
+8
-1
8 additions, 1 deletion
daemon/src/ice_transport.h
with
34 additions
and
22 deletions
daemon/src/ice_transport.cpp
+
26
−
21
View file @
46a8800d
...
@@ -45,11 +45,6 @@
...
@@ -45,11 +45,6 @@
namespace
sfl
{
namespace
sfl
{
// GLOBALS (blame PJSIP)
static
pj_caching_pool
g_cp_
;
static
pj_pool_t
*
g_pool_
=
nullptr
;
static
void
static
void
register_thread
()
register_thread
()
{
{
...
@@ -101,14 +96,20 @@ IceTransport::cb_on_ice_complete(pj_ice_strans* ice_st,
...
@@ -101,14 +96,20 @@ IceTransport::cb_on_ice_complete(pj_ice_strans* ice_st,
IceTransport
::
IceTransport
(
const
char
*
name
,
int
component_count
,
IceTransport
::
IceTransport
(
const
char
*
name
,
int
component_count
,
IceTransportCompleteCb
on_initdone_cb
,
IceTransportCompleteCb
on_initdone_cb
,
IceTransportCompleteCb
on_negodone_cb
)
IceTransportCompleteCb
on_negodone_cb
)
:
on_initdone_cb_
(
on_initdone_cb
)
:
pool_
(
nullptr
,
pj_pool_release
)
,
on_initdone_cb_
(
on_initdone_cb
)
,
on_negodone_cb_
(
on_negodone_cb
)
,
on_negodone_cb_
(
on_negodone_cb
)
,
component_count_
(
component_count
)
,
component_count_
(
component_count
)
,
compIO_
(
component_count
)
,
compIO_
(
component_count
)
{
{
auto
&
iceTransportFactory
=
Manager
::
instance
().
getIceTransportFactory
();
auto
&
iceTransportFactory
=
Manager
::
instance
().
getIceTransportFactory
();
pj_ice_strans_cb
icecb
;
pool_
.
reset
(
pj_pool_create
(
iceTransportFactory
.
getPoolFactory
(),
"IceTransport.pool"
,
512
,
512
,
NULL
));
if
(
not
pool_
)
throw
std
::
runtime_error
(
"pj_pool_create() failed"
);
pj_ice_strans_cb
icecb
;
pj_bzero
(
&
icecb
,
sizeof
(
icecb
));
pj_bzero
(
&
icecb
,
sizeof
(
icecb
));
icecb
.
on_rx_data
=
cb_on_rx_data
;
icecb
.
on_rx_data
=
cb_on_rx_data
;
icecb
.
on_ice_complete
=
cb_on_ice_complete
;
icecb
.
on_ice_complete
=
cb_on_ice_complete
;
...
@@ -454,7 +455,8 @@ IceTransport::getCandidateFromSDP(const std::string& line, IceCandidate& cand)
...
@@ -454,7 +455,8 @@ IceTransport::getCandidateFromSDP(const std::string& line, IceCandidate& cand)
}
}
pj_sockaddr_set_port
(
&
cand
.
addr
,
(
pj_uint16_t
)
port
);
pj_sockaddr_set_port
(
&
cand
.
addr
,
(
pj_uint16_t
)
port
);
pj_strdup2
(
g_pool_
,
&
cand
.
foundation
,
foundation
);
pj_strdup2
(
pool_
.
get
(),
&
cand
.
foundation
,
foundation
);
return
true
;
return
true
;
}
}
...
@@ -532,27 +534,30 @@ IceTransport::waitForData(int comp_id, unsigned int timeout)
...
@@ -532,27 +534,30 @@ IceTransport::waitForData(int comp_id, unsigned int timeout)
return
io
.
queue
.
front
().
datalen
;
return
io
.
queue
.
front
().
datalen
;
}
}
IceTransportFactory
::
IceTransportFactory
()
:
IceTransportFactory
::
IceTransportFactory
()
ice_cfg_
(),
thread_
(
nullptr
,
pj_thread_destroy
)
:
cp_
()
,
pool_
(
nullptr
,
pj_pool_release
)
,
thread_
(
nullptr
,
pj_thread_destroy
)
,
ice_cfg_
()
{
{
pj_caching_pool_init
(
&
g_
cp_
,
NULL
,
0
);
pj_caching_pool_init
(
&
cp_
,
NULL
,
0
);
g_
pool_
=
pj_pool_create
(
&
g_
cp_
.
factory
,
"
i
ce
t
ransportpool"
,
pool_
.
reset
(
pj_pool_create
(
&
cp_
.
factory
,
"
I
ce
T
ransport
Factory.
pool"
,
512
,
512
,
NULL
);
512
,
512
,
NULL
)
)
;
if
(
not
g_
pool_
)
if
(
not
pool_
)
throw
std
::
runtime_error
(
"pj_pool_create() failed"
);
throw
std
::
runtime_error
(
"pj_pool_create() failed"
);
pj_ice_strans_cfg_default
(
&
ice_cfg_
);
pj_ice_strans_cfg_default
(
&
ice_cfg_
);
ice_cfg_
.
stun_cfg
.
pf
=
&
g_
cp_
.
factory
;
ice_cfg_
.
stun_cfg
.
pf
=
&
cp_
.
factory
;
TRY
(
pj_timer_heap_create
(
g_
pool_
,
100
,
&
ice_cfg_
.
stun_cfg
.
timer_heap
)
);
TRY
(
pj_timer_heap_create
(
pool_
.
get
()
,
100
,
&
ice_cfg_
.
stun_cfg
.
timer_heap
)
);
TRY
(
pj_ioqueue_create
(
g_
pool_
,
16
,
&
ice_cfg_
.
stun_cfg
.
ioqueue
)
);
TRY
(
pj_ioqueue_create
(
pool_
.
get
()
,
16
,
&
ice_cfg_
.
stun_cfg
.
ioqueue
)
);
pj_thread_t
*
thread
=
nullptr
;
pj_thread_t
*
thread
=
nullptr
;
const
auto
&
thread_work
=
[](
void
*
udata
)
{
const
auto
&
thread_work
=
[](
void
*
udata
)
{
register_thread
();
register_thread
();
return
static_cast
<
IceTransportFactory
*>
(
udata
)
->
processThread
();
return
static_cast
<
IceTransportFactory
*>
(
udata
)
->
processThread
();
};
};
TRY
(
pj_thread_create
(
g_
pool_
,
"icetransportpool"
,
TRY
(
pj_thread_create
(
pool_
.
get
()
,
"icetransportpool"
,
thread_work
,
this
,
0
,
0
,
&
thread
)
);
thread_work
,
this
,
0
,
0
,
&
thread
)
);
thread_
.
reset
(
thread
);
thread_
.
reset
(
thread
);
...
@@ -582,8 +587,8 @@ IceTransportFactory::~IceTransportFactory()
...
@@ -582,8 +587,8 @@ IceTransportFactory::~IceTransportFactory()
if
(
ice_cfg_
.
stun_cfg
.
timer_heap
)
if
(
ice_cfg_
.
stun_cfg
.
timer_heap
)
pj_timer_heap_destroy
(
ice_cfg_
.
stun_cfg
.
timer_heap
);
pj_timer_heap_destroy
(
ice_cfg_
.
stun_cfg
.
timer_heap
);
pj_
pool_re
lease
(
g_pool_
);
pool_
.
re
set
(
);
pj_caching_pool_destroy
(
&
g_
cp_
);
pj_caching_pool_destroy
(
&
cp_
);
}
}
int
int
...
...
This diff is collapsed.
Click to expand it.
daemon/src/ice_transport.h
+
8
−
1
View file @
46a8800d
...
@@ -176,6 +176,7 @@ class IceTransport {
...
@@ -176,6 +176,7 @@ class IceTransport {
void
getDefaultCanditates
();
void
getDefaultCanditates
();
std
::
unique_ptr
<
pj_pool_t
,
decltype
(
pj_pool_release
)
&>
pool_
;
IceTransportCompleteCb
on_initdone_cb_
;
IceTransportCompleteCb
on_initdone_cb_
;
IceTransportCompleteCb
on_negodone_cb_
;
IceTransportCompleteCb
on_negodone_cb_
;
std
::
unique_ptr
<
pj_ice_strans
,
IceSTransDeleter
>
icest_
;
std
::
unique_ptr
<
pj_ice_strans
,
IceSTransDeleter
>
icest_
;
...
@@ -211,13 +212,19 @@ class IceTransportFactory {
...
@@ -211,13 +212,19 @@ class IceTransportFactory {
int
processThread
();
int
processThread
();
/**
* PJSIP specifics
*/
const
pj_ice_strans_cfg
*
getIceCfg
()
const
{
return
&
ice_cfg_
;
}
const
pj_ice_strans_cfg
*
getIceCfg
()
const
{
return
&
ice_cfg_
;
}
pj_pool_factory
*
getPoolFactory
()
{
return
&
cp_
.
factory
;
}
private
:
private
:
int
handleEvents
(
unsigned
max_msec
,
unsigned
*
p_count
);
int
handleEvents
(
unsigned
max_msec
,
unsigned
*
p_count
);
pj_caching_pool
cp_
;
std
::
unique_ptr
<
pj_pool_t
,
decltype
(
pj_pool_release
)
&>
pool_
;
std
::
unique_ptr
<
pj_thread_t
,
decltype
(
pj_thread_destroy
)
&>
thread_
;
pj_ice_strans_cfg
ice_cfg_
;
pj_ice_strans_cfg
ice_cfg_
;
std
::
unique_ptr
<
pj_thread_t
,
decltype
(
*
pj_thread_destroy
)
>
thread_
;
pj_bool_t
thread_quit_flag_
{
PJ_FALSE
};
pj_bool_t
thread_quit_flag_
{
PJ_FALSE
};
};
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment