Skip to content
Snippets Groups Projects
Commit 12900ddd authored by Antoine Noreau's avatar Antoine Noreau Committed by Sébastien Blin
Browse files

sip: ensure correct unregister upon closure

Ensure SIP connections are gracefully terminated:
Removed duplicated register calls to SIP server

Change-Id: I330e67cf9534504f92517996eb7b693b43d359d3
Gitlab: #786
parent d13df76b
No related branches found
No related tags found
No related merge requests found
...@@ -85,9 +85,7 @@ UPnPContext::shutdown() ...@@ -85,9 +85,7 @@ UPnPContext::shutdown()
std::unique_lock<std::mutex> lk(mappingMutex_); std::unique_lock<std::mutex> lk(mappingMutex_);
std::condition_variable cv; std::condition_variable cv;
runOnUpnpContextQueue([&, this] { runOnUpnpContextQueue([&, this] { shutdown(cv); });
shutdown(cv);
});
JAMI_DBG("Waiting for shutdown ..."); JAMI_DBG("Waiting for shutdown ...");
...@@ -143,7 +141,7 @@ void ...@@ -143,7 +141,7 @@ void
UPnPContext::stopUpnp(bool forceRelease) UPnPContext::stopUpnp(bool forceRelease)
{ {
if (not isValidThread()) { if (not isValidThread()) {
runOnUpnpContextQueue([this] { stopUpnp(); }); runOnUpnpContextQueue([this, forceRelease] { stopUpnp(forceRelease); });
return; return;
} }
...@@ -168,10 +166,16 @@ UPnPContext::stopUpnp(bool forceRelease) ...@@ -168,10 +166,16 @@ UPnPContext::stopUpnp(bool forceRelease)
preferredIgd_.reset(); preferredIgd_.reset();
validIgdList_.clear(); validIgdList_.clear();
} }
for (auto const& map : toRemoveList) { for (auto const& map : toRemoveList) {
requestRemoveMapping(map); requestRemoveMapping(map);
updateMappingState(map, MappingState::FAILED);
// Notify is not needed in updateMappingState when
// shutting down (hence set it to false). NotifyCallback
// would trigger a new SIP registration and create a
// false registered state upon program close.
// It's handled by upper layers.
updateMappingState(map, MappingState::FAILED, false);
// We dont remove mappings with auto-update enabled, // We dont remove mappings with auto-update enabled,
// unless forceRelease is true. // unless forceRelease is true.
if (not map->getAutoUpdate() or forceRelease) { if (not map->getAutoUpdate() or forceRelease) {
...@@ -923,9 +927,9 @@ UPnPContext::onIgdUpdated(const std::shared_ptr<IGD>& igd, UpnpIgdEvent event) ...@@ -923,9 +927,9 @@ UPnPContext::onIgdUpdated(const std::shared_ptr<IGD>& igd, UpnpIgdEvent event)
// Reset to start search for a new best IGD. // Reset to start search for a new best IGD.
preferredIgd_.reset(); preferredIgd_.reset();
char const* IgdState = event == UpnpIgdEvent::ADDED char const* IgdState = event == UpnpIgdEvent::ADDED ? "ADDED"
? "ADDED" : event == UpnpIgdEvent::REMOVED ? "REMOVED"
: event == UpnpIgdEvent::REMOVED ? "REMOVED" : "INVALID"; : "INVALID";
auto const& igdLocalAddr = igd->getLocalIp(); auto const& igdLocalAddr = igd->getLocalIp();
auto protocolName = igd->getProtocolName(); auto protocolName = igd->getProtocolName();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment