diff --git a/src/upnp/upnp_context.cpp b/src/upnp/upnp_context.cpp index 6a7273e571ab77fde1324a45ec0c7948170beae2..0bbd28242290cb786ac96b0036f02f1c5c110231 100644 --- a/src/upnp/upnp_context.cpp +++ b/src/upnp/upnp_context.cpp @@ -112,6 +112,10 @@ UPnPContext::shutdown() } else { if (logger_) logger_->error("Shutdown timed-out"); } + // NOTE: It's important to unlock mappingMutex_ here, otherwise we get a + // deadlock when the call to cv.wait_for() above times out before we return + // from proto->terminate() in shutdown(cv). + lk.unlock(); if (ioContextRunner_) { if (logger_) logger_->debug("UPnPContext: stopping io_context thread {}", fmt::ptr(this));