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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
3e542c1f
Commit
3e542c1f
authored
Sep 13, 2018
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
sipcall: protect invite session with mutex
Change-Id: I0b3573809aa5882170f27a7b0d84ad6c43f2bc3e
parent
83bcd8fb
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/call.h
+3
-3
3 additions, 3 deletions
src/call.h
src/sip/sipcall.cpp
+10
-4
10 additions, 4 deletions
src/sip/sipcall.cpp
with
13 additions
and
7 deletions
src/call.h
+
3
−
3
View file @
3e542c1f
...
@@ -339,6 +339,9 @@ class Call : public Recordable, public std::enable_shared_from_this<Call> {
...
@@ -339,6 +339,9 @@ class Call : public Recordable, public std::enable_shared_from_this<Call> {
///< MultiDevice: message waiting to be sent (need a valid subcall)
///< MultiDevice: message waiting to be sent (need a valid subcall)
MsgList
pendingOutMessages_
;
MsgList
pendingOutMessages_
;
/** Protect every attribute that can be changed by two threads */
mutable
std
::
recursive_mutex
callMutex_
{};
private
:
private
:
friend
void
hangupCallsIf
(
Call
::
SubcallSet
,
int
,
const
std
::
function
<
bool
(
Call
*
)
>&
);
friend
void
hangupCallsIf
(
Call
::
SubcallSet
,
int
,
const
std
::
function
<
bool
(
Call
*
)
>&
);
...
@@ -352,9 +355,6 @@ class Call : public Recordable, public std::enable_shared_from_this<Call> {
...
@@ -352,9 +355,6 @@ class Call : public Recordable, public std::enable_shared_from_this<Call> {
SubcallSet
safePopSubcalls
();
SubcallSet
safePopSubcalls
();
/** Protect every attribute that can be changed by two threads */
mutable
std
::
recursive_mutex
callMutex_
{};
std
::
vector
<
std
::
function
<
void
(
CallState
,
ConnectionState
,
int
)
>>
stateChangedListeners_
{};
std
::
vector
<
std
::
function
<
void
(
CallState
,
ConnectionState
,
int
)
>>
stateChangedListeners_
{};
/** Unique ID of the call */
/** Unique ID of the call */
...
...
This diff is collapsed.
Click to expand it.
src/sip/sipcall.cpp
+
10
−
4
View file @
3e542c1f
...
@@ -100,6 +100,7 @@ SIPCall::SIPCall(SIPAccountBase& account, const std::string& id, Call::CallType
...
@@ -100,6 +100,7 @@ SIPCall::SIPCall(SIPAccountBase& account, const std::string& id, Call::CallType
SIPCall
::~
SIPCall
()
SIPCall
::~
SIPCall
()
{
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lk
{
callMutex_
};
setTransport
({});
setTransport
({});
inv
.
reset
();
// prevents callback usage
inv
.
reset
();
// prevents callback usage
}
}
...
@@ -191,6 +192,7 @@ SIPCall::setTransport(const std::shared_ptr<SipTransport>& t)
...
@@ -191,6 +192,7 @@ SIPCall::setTransport(const std::shared_ptr<SipTransport>& t)
int
int
SIPCall
::
SIPSessionReinvite
()
SIPCall
::
SIPSessionReinvite
()
{
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lk
{
callMutex_
};
// Do nothing if no invitation processed yet
// Do nothing if no invitation processed yet
if
(
not
inv
or
inv
->
invite_tsx
)
if
(
not
inv
or
inv
->
invite_tsx
)
return
PJ_SUCCESS
;
return
PJ_SUCCESS
;
...
@@ -236,10 +238,13 @@ SIPCall::SIPSessionReinvite()
...
@@ -236,10 +238,13 @@ SIPCall::SIPSessionReinvite()
void
void
SIPCall
::
sendSIPInfo
(
const
char
*
const
body
,
const
char
*
const
subtype
)
SIPCall
::
sendSIPInfo
(
const
char
*
const
body
,
const
char
*
const
subtype
)
{
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lk
{
callMutex_
};
if
(
not
inv
or
not
inv
->
dlg
)
if
(
not
inv
or
not
inv
->
dlg
)
throw
VoipLinkException
(
"Couldn't get invite dialog"
);
throw
VoipLinkException
(
"Couldn't get invite dialog"
);
pj_str_t
methodName
=
CONST_PJ_STR
(
"INFO"
);
pj_str_t
methodName
=
CONST_PJ_STR
(
"INFO"
);
const
pj_str_t
type
=
CONST_PJ_STR
(
"application"
);
pjsip_method
method
;
pjsip_method
method
;
pjsip_method_init_np
(
&
method
,
&
methodName
);
pjsip_method_init_np
(
&
method
,
&
methodName
);
...
@@ -254,11 +259,9 @@ SIPCall::sendSIPInfo(const char *const body, const char *const subtype)
...
@@ -254,11 +259,9 @@ SIPCall::sendSIPInfo(const char *const body, const char *const subtype)
/* Create "application/<subtype>" message body. */
/* Create "application/<subtype>" message body. */
pj_str_t
content
;
pj_str_t
content
;
pj_cstr
(
&
content
,
body
);
pj_cstr
(
&
content
,
body
);
const
pj_str_t
type
=
CONST_PJ_STR
(
"application"
);
pj_str_t
pj_subtype
;
pj_str_t
pj_subtype
;
pj_cstr
(
&
pj_subtype
,
subtype
);
pj_cstr
(
&
pj_subtype
,
subtype
);
tdata
->
msg
->
body
=
pjsip_msg_body_create
(
tdata
->
pool
,
&
type
,
&
pj_subtype
,
&
content
);
tdata
->
msg
->
body
=
pjsip_msg_body_create
(
tdata
->
pool
,
&
type
,
&
pj_subtype
,
&
content
);
if
(
tdata
->
msg
->
body
==
NULL
)
if
(
tdata
->
msg
->
body
==
NULL
)
pjsip_tx_data_dec_ref
(
tdata
);
pjsip_tx_data_dec_ref
(
tdata
);
else
else
...
@@ -274,9 +277,9 @@ SIPCall::updateSDPFromSTUN()
...
@@ -274,9 +277,9 @@ SIPCall::updateSDPFromSTUN()
void
void
SIPCall
::
terminateSipSession
(
int
status
)
SIPCall
::
terminateSipSession
(
int
status
)
{
{
if
(
inv
and
inv
->
state
!=
PJSIP_INV_STATE_DISCONNECTED
)
{
RING_DBG
(
"[call:%s] Terminate SIP session"
,
getCallId
().
c_str
());
RING_DBG
(
"[call:%s] Terminate SIP session"
,
getCallId
().
c_str
());
std
::
lock_guard
<
std
::
recursive_mutex
>
lk
{
callMutex_
};
if
(
inv
and
inv
->
state
!=
PJSIP_INV_STATE_DISCONNECTED
)
{
pjsip_tx_data
*
tdata
=
nullptr
;
pjsip_tx_data
*
tdata
=
nullptr
;
auto
ret
=
pjsip_inv_end_session
(
inv
.
get
(),
status
,
nullptr
,
&
tdata
);
auto
ret
=
pjsip_inv_end_session
(
inv
.
get
(),
status
,
nullptr
,
&
tdata
);
if
(
ret
==
PJ_SUCCESS
)
{
if
(
ret
==
PJ_SUCCESS
)
{
...
@@ -299,6 +302,7 @@ SIPCall::terminateSipSession(int status)
...
@@ -299,6 +302,7 @@ SIPCall::terminateSipSession(int status)
void
void
SIPCall
::
answer
()
SIPCall
::
answer
()
{
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lk
{
callMutex_
};
auto
&
account
=
getSIPAccount
();
auto
&
account
=
getSIPAccount
();
if
(
not
inv
)
if
(
not
inv
)
...
@@ -343,6 +347,7 @@ SIPCall::answer()
...
@@ -343,6 +347,7 @@ SIPCall::answer()
void
void
SIPCall
::
hangup
(
int
reason
)
SIPCall
::
hangup
(
int
reason
)
{
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lk
{
callMutex_
};
if
(
inv
and
inv
->
dlg
)
{
if
(
inv
and
inv
->
dlg
)
{
pjsip_route_hdr
*
route
=
inv
->
dlg
->
route_set
.
next
;
pjsip_route_hdr
*
route
=
inv
->
dlg
->
route_set
.
next
;
while
(
route
and
route
!=
&
inv
->
dlg
->
route_set
)
{
while
(
route
and
route
!=
&
inv
->
dlg
->
route_set
)
{
...
@@ -698,6 +703,7 @@ SIPCall::sendTextMessage(const std::map<std::string, std::string>& messages,
...
@@ -698,6 +703,7 @@ SIPCall::sendTextMessage(const std::map<std::string, std::string>& messages,
void
void
SIPCall
::
removeCall
()
SIPCall
::
removeCall
()
{
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lk
{
callMutex_
};
RING_WARN
(
"[call:%s] removeCall()"
,
getCallId
().
c_str
());
RING_WARN
(
"[call:%s] removeCall()"
,
getCallId
().
c_str
());
Call
::
removeCall
();
Call
::
removeCall
();
mediaTransport_
.
reset
();
mediaTransport_
.
reset
();
...
...
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