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