提交 2b76b620 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

Fix worker 100% CPU usage due to wrong iteration in Router.cpp destructor

上级 d4854d93
......@@ -68,7 +68,6 @@ namespace RTC
virtual ~Transport();
public:
void Close();
virtual Json::Value ToJson() const = 0;
virtual Json::Value GetStats() const = 0;
void HandleProducer(RTC::Producer* producer);
......@@ -129,8 +128,6 @@ namespace RTC
Timer* rtcpTimer{ nullptr };
RTC::UdpSocket* mirrorSocket{ nullptr };
RTC::TransportTuple* mirrorTuple{ nullptr };
// Others.
bool closed{ false };
// Others (Producers and Consumers).
std::unordered_set<RTC::Producer*> producers;
std::unordered_set<RTC::Consumer*> consumers;
......
......@@ -59,9 +59,8 @@ namespace RTC
{
auto* transport = it->second;
// Do not delete the Transport but call to its Close() method so it will call us
// on OnTransportClosed() and will delete it there.
transport->Close();
it = this->transports.erase(it);
delete transport;
}
// Close the audio level timer.
......@@ -595,12 +594,10 @@ namespace RTC
return;
}
// Do not delete the Transport but call to its Close() method so it will call us
// on OnTransportClosed() and will delete it there.
transport->Close();
MS_DEBUG_DEV("Transport closed [transportId:%" PRIu32 "]", transport->transportId);
delete transport;
request->Accept();
break;
......@@ -995,10 +992,10 @@ namespace RTC
return;
}
delete producer;
MS_DEBUG_DEV("Producer closed [producerId:%" PRIu32 "]", producer->producerId);
delete producer;
request->Accept();
break;
......@@ -1167,6 +1164,8 @@ namespace RTC
return;
}
MS_DEBUG_DEV("Consumer closed [consumerId:%" PRIu32 "]", consumer->consumerId);
delete consumer;
request->Accept();
......@@ -1598,8 +1597,6 @@ namespace RTC
MS_TRACE();
this->transports.erase(transport->transportId);
delete transport;
}
void Router::OnProducerClosed(RTC::Producer* producer)
......
......@@ -34,19 +34,6 @@ namespace RTC
{
MS_TRACE();
if (!this->closed)
Close();
}
void Transport::Close()
{
MS_TRACE();
if (this->closed)
return;
this->closed = true;
// Close all the handled Producers.
for (auto it = this->producers.begin(); it != this->producers.end();)
{
......
......@@ -1181,9 +1181,6 @@ namespace RTC
// Notify.
eventData[JsonStringDtlsState] = JsonStringFailed;
this->notifier->Emit(this->transportId, "dtlsstatechange", eventData);
// This is a fatal error so close the transport.
Close();
}
void WebRtcTransport::OnDtlsClosed(const RTC::DtlsTransport* /*dtlsTransport*/)
......@@ -1200,9 +1197,6 @@ namespace RTC
// Notify.
eventData[JsonStringDtlsState] = JsonStringClosed;
this->notifier->Emit(this->transportId, "dtlsstatechange", eventData);
// This is a fatal error so close the transport.
Close();
}
void WebRtcTransport::OnOutgoingDtlsData(
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论