Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
78763f4c
Unverified
提交
78763f4c
authored
6月 02, 2021
作者:
Iñaki Baz Castillo
提交者:
GitHub
6月 02, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix DepUsrSCTP::Checker::timer not being freed (#576)
上级
6b6d8cec
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
95 行增加
和
8 行删除
+95
-8
DepUsrSCTP.hpp
worker/include/DepUsrSCTP.hpp
+2
-0
DepLibUV.cpp
worker/src/DepLibUV.cpp
+44
-4
DepUsrSCTP.cpp
worker/src/DepUsrSCTP.cpp
+24
-4
Worker.cpp
worker/src/Worker.cpp
+7
-0
TestKeyFrameRequestManager.cpp
worker/test/src/RTC/TestKeyFrameRequestManager.cpp
+10
-0
TestNackGenerator.cpp
worker/test/src/RTC/TestNackGenerator.cpp
+4
-0
TestRtpStreamRecv.cpp
worker/test/src/RTC/TestRtpStreamRecv.cpp
+4
-0
没有找到文件。
worker/include/DepUsrSCTP.hpp
浏览文件 @
78763f4c
...
...
@@ -31,6 +31,8 @@ private:
public
:
static
void
ClassInit
();
static
void
ClassDestroy
();
static
void
CreateChecker
();
static
void
CloseChecker
();
static
uintptr_t
GetNextSctpAssociationId
();
static
void
RegisterSctpAssociation
(
RTC
::
SctpAssociation
*
sctpAssociation
);
static
void
DeregisterSctpAssociation
(
RTC
::
SctpAssociation
*
sctpAssociation
);
...
...
worker/src/DepLibUV.cpp
浏览文件 @
78763f4c
...
...
@@ -9,6 +9,27 @@
thread_local
uv_loop_t
*
DepLibUV
::
loop
{
nullptr
};
/* Static methods for UV callbacks. */
inline
static
void
onClose
(
uv_handle_t
*
handle
)
{
delete
handle
;
}
inline
static
void
onWalk
(
uv_handle_t
*
handle
,
void
*
arg
)
{
// Must use MS_ERROR_STD since at this point the Channel is already closed.
MS_ERROR_STD
(
"alive UV handle found (this shouldn't happen) [type:%d, active:%d, closing:%d, has_ref:%d]"
,
handle
->
type
,
uv_is_active
(
handle
),
uv_is_closing
(
handle
),
uv_has_ref
(
handle
));
if
(
!
uv_is_closing
(
handle
))
uv_close
(
handle
,
onClose
);
}
/* Static methods. */
void
DepLibUV
::
ClassInit
()
...
...
@@ -20,18 +41,37 @@ void DepLibUV::ClassInit()
int
err
=
uv_loop_init
(
DepLibUV
::
loop
);
if
(
err
!=
0
)
MS_ABORT
(
"libuv initialization failed"
);
MS_ABORT
(
"libuv
loop
initialization failed"
);
}
void
DepLibUV
::
ClassDestroy
()
{
MS_TRACE
();
if
(
DepLibUV
::
loop
!=
nullptr
)
// Here we should not have any UV handle left. All them should have been
// already closed+freed. However, in order to not introduce regressions
// in the future, we check this anyway.
// More context: https://github.com/versatica/mediasoup/pull/576
int
err
;
uv_stop
(
DepLibUV
::
loop
);
uv_walk
(
DepLibUV
::
loop
,
onWalk
,
nullptr
);
while
(
true
)
{
uv_loop_close
(
DepLibUV
::
loop
);
delete
DepLibUV
::
loop
;
err
=
uv_loop_close
(
DepLibUV
::
loop
);
if
(
err
!=
UV_EBUSY
)
break
;
uv_run
(
DepLibUV
::
loop
,
UV_RUN_NOWAIT
);
}
if
(
err
!=
0
)
MS_ERROR_STD
(
"failed to close libuv loop: %s"
,
uv_err_name
(
err
));
delete
DepLibUV
::
loop
;
}
void
DepLibUV
::
PrintVersion
()
...
...
worker/src/DepUsrSCTP.cpp
浏览文件 @
78763f4c
...
...
@@ -82,8 +82,6 @@ void DepUsrSCTP::ClassInit()
++
globalInstances
;
}
DepUsrSCTP
::
checker
=
new
DepUsrSCTP
::
Checker
();
}
void
DepUsrSCTP
::
ClassDestroy
()
...
...
@@ -97,13 +95,31 @@ void DepUsrSCTP::ClassDestroy()
if
(
globalInstances
==
0
)
{
usrsctp_finish
();
// TODO: This cleanup currently causes assertion errors in
// DepUsrSCTP::DeregisterSctpAssociation()
// TODO: This cleanup currently causes assertion errors in
// DepUsrSCTP::DeregisterSctpAssociation() when using mediasoup-worker
// in thread mode (Rust).
//
// numSctpAssociations = 0u; nextSctpAssociationId = 0u;
// DepUsrSCTP::mapIdSctpAssociation.clear();
}
}
}
void
DepUsrSCTP
::
CreateChecker
()
{
MS_TRACE
();
MS_ASSERT
(
DepUsrSCTP
::
checker
==
nullptr
,
"Checker already created"
);
DepUsrSCTP
::
checker
=
new
DepUsrSCTP
::
Checker
();
}
void
DepUsrSCTP
::
CloseChecker
()
{
MS_TRACE
();
MS_ASSERT
(
DepUsrSCTP
::
checker
!=
nullptr
,
"Checker not created"
);
delete
DepUsrSCTP
::
checker
;
}
...
...
@@ -138,6 +154,8 @@ void DepUsrSCTP::RegisterSctpAssociation(RTC::SctpAssociation* sctpAssociation)
std
::
lock_guard
<
std
::
mutex
>
lock
(
globalSyncMutex
);
MS_ASSERT
(
DepUsrSCTP
::
checker
!=
nullptr
,
"Checker not created"
);
auto
it
=
DepUsrSCTP
::
mapIdSctpAssociation
.
find
(
sctpAssociation
->
id
);
MS_ASSERT
(
...
...
@@ -156,6 +174,8 @@ void DepUsrSCTP::DeregisterSctpAssociation(RTC::SctpAssociation* sctpAssociation
std
::
lock_guard
<
std
::
mutex
>
lock
(
globalSyncMutex
);
MS_ASSERT
(
DepUsrSCTP
::
checker
!=
nullptr
,
"Checker not created"
);
auto
found
=
DepUsrSCTP
::
mapIdSctpAssociation
.
erase
(
sctpAssociation
->
id
);
MS_ASSERT
(
found
>
0
,
"SctpAssociation not found"
);
...
...
worker/src/Worker.cpp
浏览文件 @
78763f4c
...
...
@@ -3,6 +3,7 @@
#include "Worker.hpp"
#include "DepLibUV.hpp"
#include "DepUsrSCTP.hpp"
#include "Logger.hpp"
#include "MediaSoupErrors.hpp"
#include "Settings.hpp"
...
...
@@ -32,6 +33,9 @@ Worker::Worker(::Channel::ChannelSocket* channel, PayloadChannel::PayloadChannel
}
#endif
// Create the Checker instance in DepUsrSCTP.
DepUsrSCTP
::
CreateChecker
();
// Tell the Node process that we are running.
Channel
::
ChannelNotifier
::
Emit
(
std
::
to_string
(
Logger
::
pid
),
"running"
);
...
...
@@ -75,6 +79,9 @@ void Worker::Close()
}
this
->
mapRouters
.
clear
();
// Close the Checker instance in DepUsrSCTP.
DepUsrSCTP
::
CloseChecker
();
// Close the Channel.
this
->
channel
->
Close
();
...
...
worker/test/src/RTC/TestKeyFrameRequestManager.cpp
浏览文件 @
78763f4c
...
...
@@ -33,6 +33,7 @@ SCENARIO("KeyFrameRequestManager", "[rtp][keyframe]")
keyFrameRequestManager
.
KeyFrameNeeded
(
1111
);
// Must run the loop here to consume the timer before doing the check.
DepLibUV
::
RunLoop
();
REQUIRE
(
listener
.
onKeyFrameNeededTimesCalled
==
2
);
...
...
@@ -48,6 +49,7 @@ SCENARIO("KeyFrameRequestManager", "[rtp][keyframe]")
keyFrameRequestManager
.
KeyFrameNeeded
(
1111
);
keyFrameRequestManager
.
KeyFrameNeeded
(
1111
);
// Must run the loop here to consume the timer before doing the check.
DepLibUV
::
RunLoop
();
REQUIRE
(
listener
.
onKeyFrameNeededTimesCalled
==
2
);
...
...
@@ -61,6 +63,7 @@ SCENARIO("KeyFrameRequestManager", "[rtp][keyframe]")
keyFrameRequestManager
.
KeyFrameNeeded
(
1111
);
keyFrameRequestManager
.
KeyFrameReceived
(
1111
);
// Must run the loop here to consume the timer before doing the check.
DepLibUV
::
RunLoop
();
REQUIRE
(
listener
.
onKeyFrameNeededTimesCalled
==
1
);
...
...
@@ -74,6 +77,7 @@ SCENARIO("KeyFrameRequestManager", "[rtp][keyframe]")
keyFrameRequestManager
.
KeyFrameNeeded
(
1111
);
keyFrameRequestManager
.
ForceKeyFrameNeeded
(
1111
);
// Must run the loop here to consume the timer before doing the check.
DepLibUV
::
RunLoop
();
REQUIRE
(
listener
.
onKeyFrameNeededTimesCalled
==
3
);
...
...
@@ -88,8 +92,14 @@ SCENARIO("KeyFrameRequestManager", "[rtp][keyframe]")
keyFrameRequestManager
.
ForceKeyFrameNeeded
(
1111
);
keyFrameRequestManager
.
KeyFrameReceived
(
1111
);
// Must run the loop here to consume the timer before doing the check.
DepLibUV
::
RunLoop
();
REQUIRE
(
listener
.
onKeyFrameNeededTimesCalled
==
2
);
}
// Must run the loop to wait for UV timers and close them.
// NOTE: Not really needed in this file since we run it in each SECTION in
// purpose.
DepLibUV
::
RunLoop
();
}
worker/test/src/RTC/TestNackGenerator.cpp
浏览文件 @
78763f4c
#include "common.hpp"
#include "DepLibUV.hpp"
#include "RTC/Codecs/PayloadDescriptorHandler.hpp"
#include "RTC/NackGenerator.hpp"
#include "RTC/RtpPacket.hpp"
...
...
@@ -278,4 +279,7 @@ SCENARIO("NACK generator", "[rtp][rtcp]")
validate
(
inputs
);
}
// Must run the loop to wait for UV timers and close them.
DepLibUV
::
RunLoop
();
}
worker/test/src/RTC/TestRtpStreamRecv.cpp
浏览文件 @
78763f4c
#include "common.hpp"
#include "DepLibUV.hpp"
#include "RTC/RtpPacket.hpp"
#include "RTC/RtpStream.hpp"
#include "RTC/RtpStreamRecv.hpp"
...
...
@@ -201,5 +202,8 @@ SCENARIO("receive RTP packets and trigger NACK", "[rtp][rtpstream]")
rtpStream
.
ReceivePacket
(
packet
);
}
// Must run the loop to wait for UV timers and close them.
DepLibUV
::
RunLoop
();
delete
packet
;
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论