Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
E
evsuits
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
OpsTeam
evsuits
Commits
001c6a1e
提交
001c6a1e
authored
1月 15, 2020
作者:
blu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
bugfix: singleton process
上级
99764402
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
87 行增加
和
0 行删除
+87
-0
a.out
opencv-motion-detect/a.out
+0
-0
evmgr.cpp
opencv-motion-detect/evmgr.cpp
+0
-0
evmlmotion.cpp
opencv-motion-detect/evmlmotion.cpp
+0
-0
evpuller.cpp
opencv-motion-detect/evpuller.cpp
+0
-0
evpusher.cpp
opencv-motion-detect/evpusher.cpp
+0
-0
evslicer.cpp
opencv-motion-detect/evslicer.cpp
+0
-0
singprocess.hpp
opencv-motion-detect/singprocess.hpp
+87
-0
没有找到文件。
opencv-motion-detect/a.out
0 → 100755
浏览文件 @
001c6a1e
File added
opencv-motion-detect/evmgr.cpp
浏览文件 @
001c6a1e
差异被折叠。
点击展开。
opencv-motion-detect/evmlmotion.cpp
浏览文件 @
001c6a1e
差异被折叠。
点击展开。
opencv-motion-detect/evpuller.cpp
浏览文件 @
001c6a1e
差异被折叠。
点击展开。
opencv-motion-detect/evpusher.cpp
浏览文件 @
001c6a1e
差异被折叠。
点击展开。
opencv-motion-detect/evslicer.cpp
浏览文件 @
001c6a1e
差异被折叠。
点击展开。
opencv-motion-detect/singprocess.hpp
0 → 100644
浏览文件 @
001c6a1e
#include <netinet/in.h>
class
SingletonProcess
{
private
:
uint16_t
name2port
(
string
name
)
{
uint16_t
ret
=
41070
;
if
(
name
==
"evdaemon"
)
{
//
}
else
if
(
name
==
"evmgr"
)
{
ret
+=
100
;
}
else
if
(
name
==
"evpuller"
)
{
ret
+=
200
;
}
else
if
(
name
==
"evpusher"
)
{
ret
+=
300
;
}
else
if
(
name
==
"evslicer"
)
{
ret
+=
400
;
}
else
if
(
name
==
"evmlmotion"
)
{
ret
+=
500
;
}
else
if
(
name
==
"evwifi"
)
{
ret
+=
600
;
}
else
{
ret
+=
900
;
}
return
ret
;
}
public
:
SingletonProcess
(
uint16_t
port0
)
:
socket_fd
(
-
1
)
,
rc
(
1
)
,
port
(
port0
)
{
}
SingletonProcess
(
string
moduName
,
uint16_t
iid
)
:
socket_fd
(
-
1
)
,
rc
(
1
)
{
port
=
name2port
(
moduName
)
+
iid
;
}
~
SingletonProcess
()
{
if
(
socket_fd
!=
-
1
)
{
close
(
socket_fd
);
}
}
bool
operator
()()
{
if
(
socket_fd
==
-
1
||
rc
)
{
socket_fd
=
-
1
;
rc
=
1
;
if
((
socket_fd
=
socket
(
AF_INET
,
SOCK_DGRAM
,
0
))
<
0
)
{
throw
std
::
runtime_error
(
std
::
string
(
"Could not create socket: "
)
+
strerror
(
errno
));
}
else
{
struct
sockaddr_in
name
;
name
.
sin_family
=
AF_INET
;
name
.
sin_port
=
htons
(
port
);
name
.
sin_addr
.
s_addr
=
htonl
(
INADDR_ANY
);
rc
=
::
bind
(
socket_fd
,
(
struct
sockaddr
*
)
&
name
,
sizeof
(
name
));
}
}
return
(
socket_fd
!=
-
1
&&
rc
==
0
);
}
std
::
string
GetLockFileName
()
{
return
std
::
to_string
(
port
);
}
private
:
int
socket_fd
=
-
1
;
int
rc
;
uint16_t
port
;
};
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论