Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
5525406f
提交
5525406f
authored
1月 15, 2016
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Avoid a crash due to double uv_close() in TCPServer handler.
上级
d5ef3502
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
18 行增加
和
2 行删除
+18
-2
TCPServer.cpp
worker/src/handles/TCPServer.cpp
+18
-2
没有找到文件。
worker/src/handles/TCPServer.cpp
浏览文件 @
5525406f
...
@@ -278,6 +278,19 @@ void TCPServer::onTCPConnectionClosed(TCPConnection* connection, bool is_closed_
...
@@ -278,6 +278,19 @@ void TCPServer::onTCPConnectionClosed(TCPConnection* connection, bool is_closed_
{
{
MS_TRACE
();
MS_TRACE
();
// NOTE:
// Worst scenario is that in which this is the latest connection,
// which is remotely closed (no TCPServer.Close() was called) and the user
// call TCPServer.Close() on userOnTCPConnectionClosed() callback, so Close()
// is called with zero connections and calls uv_close(), but then
// onTCPConnectionClosed() continues and finds that isClosing is true and
// there are zero connections, so calls uv_close() again and get a crash.
//
// SOLUTION:
// Check isClosing value *before* onTCPConnectionClosed() callback.
bool
wasClosing
=
this
->
isClosing
;
MS_DEBUG
(
"TCP connection closed:"
);
MS_DEBUG
(
"TCP connection closed:"
);
connection
->
Dump
();
connection
->
Dump
();
...
@@ -287,8 +300,11 @@ void TCPServer::onTCPConnectionClosed(TCPConnection* connection, bool is_closed_
...
@@ -287,8 +300,11 @@ void TCPServer::onTCPConnectionClosed(TCPConnection* connection, bool is_closed_
// Notify the subclass.
// Notify the subclass.
userOnTCPConnectionClosed
(
connection
,
is_closed_by_peer
);
userOnTCPConnectionClosed
(
connection
,
is_closed_by_peer
);
// Check if the server is closing connections and if this is the last
// TODO: CRASH: in userOnTCPConnectionClosed callback the app can call Close()
// on this TCPServer so we end calling uv_close() twice and crash!
// Check if the server was closing connections, and if this is the last
// connection then close the server now.
// connection then close the server now.
if
(
this
->
i
sClosing
&&
this
->
connections
.
empty
())
if
(
wa
sClosing
&&
this
->
connections
.
empty
())
uv_close
((
uv_handle_t
*
)
this
->
uvHandle
,
(
uv_close_cb
)
on_close
);
uv_close
((
uv_handle_t
*
)
this
->
uvHandle
,
(
uv_close_cb
)
on_close
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论