Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
6b8c8747
提交
6b8c8747
authored
1月 01, 2016
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Worker: Remove Socket utils.
上级
4d3e285a
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
0 行增加
和
108 行删除
+0
-108
Utils.h
worker/include/Utils.h
+0
-20
Socket.cpp
worker/src/Utils/Socket.cpp
+0
-88
没有找到文件。
worker/include/Utils.h
浏览文件 @
6b8c8747
...
@@ -73,26 +73,6 @@ namespace Utils
...
@@ -73,26 +73,6 @@ namespace Utils
return
copied_addr
;
return
copied_addr
;
}
}
class
Socket
{
public
:
/**
* Builds a pair of connected sockets. The sockets are created in non-blocking
* mode and with close-exec (so they are closed after fork()).
*
* @param family Socket family (AF_UNIX...).
* @param type Socket type (SOCK_DGRAM...) + flags.
* @param fds Array with two integers.
*
* In case of error throws a MediaSoupError exception.
*/
static
void
BuildSocketPair
(
int
family
,
int
type
,
int
*
fds
);
private
:
static
bool
SetNonBlock
(
int
fd
);
static
bool
SetCloExec
(
int
fd
);
};
class
File
class
File
{
{
public
:
public
:
...
...
worker/src/Utils/Socket.cpp
deleted
100644 → 0
浏览文件 @
4d3e285a
#define MS_CLASS "Utils::Socket"
#include "Utils.h"
#include "MediaSoupError.h"
#include "Logger.h"
#include <cerrno>
#include <fcntl.h>
namespace
Utils
{
void
Socket
::
BuildSocketPair
(
int
family
,
int
type
,
int
*
fds
)
{
MS_TRACE
();
// Old Linux/BSD kernels and OSX don't support setting SOCK_NONBLOCK and/or
// SOCK_CLOEXEC during socket creation. In those cases use fcntl().
#if defined(SOCK_NONBLOCK)
type
|=
SOCK_NONBLOCK
;
#endif
#if defined(SOCK_CLOEXEC)
type
|=
SOCK_CLOEXEC
;
#endif
// Create a pair of connected sockets.
if
(
socketpair
(
family
,
type
,
0
,
fds
))
MS_THROW_ERROR
(
"socketpair() failed: %s"
,
std
::
strerror
(
errno
));
#if !defined(SOCK_NONBLOCK)
if
(
!
(
SetNonBlock
(
fds
[
0
])
&&
SetNonBlock
(
fds
[
1
])))
MS_THROW_ERROR
(
"error setting sockets as non-blocking"
);
#endif
#if !defined(SOCK_CLOEXEC)
if
(
!
(
SetCloExec
(
fds
[
0
])
&&
SetCloExec
(
fds
[
1
])))
MS_THROW_ERROR
(
"error setting sockets as close-exec"
);
#endif
}
bool
Socket
::
SetNonBlock
(
int
fd
)
{
MS_TRACE
();
int
flags
;
int
ret
;
flags
=
fcntl
(
fd
,
F_GETFL
);
if
(
flags
==
-
1
)
{
MS_ERROR
(
"fcntl() failed when getting flags"
);
return
false
;
}
ret
=
fcntl
(
fd
,
F_SETFL
,
flags
|
O_NONBLOCK
);
if
(
ret
==
-
1
)
{
MS_ERROR
(
"fcntl() failed when setting O_NONBLOCK: %s"
,
std
::
strerror
(
errno
));
return
false
;
}
return
true
;
}
bool
Socket
::
SetCloExec
(
int
fd
)
{
MS_TRACE
();
int
flags
;
int
ret
;
flags
=
fcntl
(
fd
,
F_GETFD
);
if
(
flags
==
-
1
)
{
MS_ERROR
(
"fcntl() failed when getting flags"
);
return
false
;
}
ret
=
fcntl
(
fd
,
F_SETFD
,
flags
|
FD_CLOEXEC
);
if
(
ret
==
-
1
)
{
MS_ERROR
(
"fcntl() failed when setting FD_CLOEXEC: %s"
,
std
::
strerror
(
errno
));
return
false
;
}
return
true
;
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论