Skip to content
Snippets Groups Projects
Commit f6baf4b8 authored by Sébastien Blin's avatar Sébastien Blin Committed by Adrien Béraud
Browse files

natpmp: avoid to post after context shutdown

Else, a deadlock may occurs

jami-daemon#936
Change-Id: Ib4a02845bd0b7e5d482f3fc5f5c8b8a01a50a80f
parent b4646052
Branches
No related tags found
No related merge requests found
...@@ -676,7 +676,13 @@ NatPmp::processIgdUpdate(UpnpIgdEvent event) ...@@ -676,7 +676,13 @@ NatPmp::processIgdUpdate(UpnpIgdEvent event)
if (observer_ == nullptr) if (observer_ == nullptr)
return; return;
// Process the response on the context thread. // Process the response on the context thread.
ioContext->post([obs = observer_, igd = igd_, event] { obs->onIgdUpdated(igd, event); }); ioContext->post([w = weak(), event] {
if (auto shared = w.lock()) {
if (!shared->shutdownComplete_) {
shared->observer_->onIgdUpdated(shared->igd_, event);
}
}
});
} }
void void
...@@ -686,7 +692,13 @@ NatPmp::processMappingAdded(const Mapping& map) ...@@ -686,7 +692,13 @@ NatPmp::processMappingAdded(const Mapping& map)
return; return;
// Process the response on the context thread. // Process the response on the context thread.
ioContext->post([obs = observer_, igd = igd_, map] { obs->onMappingAdded(igd, map); }); ioContext->post([w=weak(), map] {
if (auto shared = w.lock()) {
if (!shared->shutdownComplete_) {
shared->observer_->onMappingAdded(shared->igd_, map);
}
}
});
} }
void void
...@@ -696,7 +708,13 @@ NatPmp::processMappingRequestFailed(const Mapping& map) ...@@ -696,7 +708,13 @@ NatPmp::processMappingRequestFailed(const Mapping& map)
return; return;
// Process the response on the context thread. // Process the response on the context thread.
ioContext->post([obs = observer_, igd = igd_, map] { obs->onMappingRequestFailed(map); }); ioContext->post([w=weak(), map] {
if (auto shared = w.lock()) {
if (!shared->shutdownComplete_) {
shared->observer_->onMappingRequestFailed(map);
}
}
});
} }
void void
...@@ -706,7 +724,13 @@ NatPmp::processMappingRenewed(const Mapping& map) ...@@ -706,7 +724,13 @@ NatPmp::processMappingRenewed(const Mapping& map)
return; return;
// Process the response on the context thread. // Process the response on the context thread.
ioContext->post([obs = observer_, igd = igd_, map] { obs->onMappingRenewed(igd, map); }); ioContext->post([w=weak(), map] {
if (auto shared = w.lock()) {
if (!shared->shutdownComplete_) {
shared->observer_->onMappingRenewed(shared->igd_, map);
}
}
});
} }
void void
...@@ -716,7 +740,13 @@ NatPmp::processMappingRemoved(const Mapping& map) ...@@ -716,7 +740,13 @@ NatPmp::processMappingRemoved(const Mapping& map)
return; return;
// Process the response on the context thread. // Process the response on the context thread.
ioContext->post([obs = observer_, igd = igd_, map] { obs->onMappingRemoved(igd, map); }); ioContext->post([w=weak(), map] {
if (auto shared = w.lock()) {
if (!shared->shutdownComplete_) {
shared->observer_->onMappingRemoved(shared->igd_, map);
}
}
});
} }
} // namespace upnp } // namespace upnp
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment