Skip to content

Commit

Permalink
conference: fix possible deadlock when changing media
Browse files Browse the repository at this point in the history
This patch executes handleMediaChangeRequest on a thread pool
to avoid potential deadlocks. Since handleMediaChangeRequest
locks callMutex, it could cause a deadlock if sendSIPInfo is called
at the same time.

GitLab: #915

Change-Id: I7e79eef0dd00f2814ba360fc8a6e96ff107285c8
  • Loading branch information
katekm committed Nov 15, 2023
1 parent 6c433a0 commit 60374fa
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/sip/sipcall.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* Copyright (C) 2004-2023 Savoir-faire Linux Inc.
*
* Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
Expand Down Expand Up @@ -2946,14 +2946,18 @@ SIPCall::onReceiveReinvite(const pjmedia_sdp_session* offer, pjsip_rx_data* rdat
return res;
}

// Report the change request.
auto const& remoteMediaList = MediaAttribute::mediaAttributesToMediaMaps(mediaAttrList);
dht::ThreadPool::io().run([callWkPtr = weak(), mediaAttrList] {
if (auto call = callWkPtr.lock()) {
// Report the change request.
auto const& remoteMediaList = MediaAttribute::mediaAttributesToMediaMaps(mediaAttrList);
if (auto conf = call->getConference()) {
conf->handleMediaChangeRequest(call, remoteMediaList);
} else {
call->handleMediaChangeRequest(remoteMediaList);
}
}
});

if (auto conf = getConference()) {
conf->handleMediaChangeRequest(shared_from_this(), remoteMediaList);
} else {
handleMediaChangeRequest(remoteMediaList);
}
return res;
}

Expand Down

0 comments on commit 60374fa

Please sign in to comment.