Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
youngwolf
ascs
提交
e00bbb93
A
ascs
项目概览
youngwolf
/
ascs
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
ascs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e00bbb93
编写于
7月 13, 2020
作者:
Y
youngwolf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix the closure of UNIX domain UDP socket.
上级
458b86e3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
7 addition
and
8 deletion
+7
-8
examples/unix_udp_test/unix_udp_test.cpp
examples/unix_udp_test/unix_udp_test.cpp
+0
-3
include/ascs/socket.h
include/ascs/socket.h
+2
-2
include/ascs/udp/socket.h
include/ascs/udp/socket.h
+5
-3
未找到文件。
examples/unix_udp_test/unix_udp_test.cpp
浏览文件 @
e00bbb93
...
...
@@ -2,9 +2,6 @@
#include <iostream>
//configuration
#define ASCS_DELAY_CLOSE 1 //this demo not used object pool and doesn't need life cycle management,
//so, define this to avoid hooks for async call (and slightly improve efficiency),
//any value which is bigger than zero is okay.
//configuration
#include <ascs/ext/udp.h>
...
...
include/ascs/socket.h
浏览文件 @
e00bbb93
...
...
@@ -385,7 +385,7 @@ protected:
#endif
//subclass notify shutdown event
bool
close
(
)
bool
close
(
bool
use_close
=
false
)
//if not use_close, shutdown (both direction) will be used
{
scope_atomic_lock
lock
(
start_atomic
);
while
(
!
lock
.
locked
())
...
...
@@ -405,7 +405,7 @@ protected:
if
(
lowest_layer
().
is_open
())
{
asio
::
error_code
ec
;
lowest_layer
().
shutdown
(
Family
::
socket
::
shutdown_both
,
ec
);
use_close
?
lowest_layer
().
close
(
ec
)
:
lowest_layer
().
shutdown
(
Family
::
socket
::
shutdown_both
,
ec
);
stat
.
break_time
=
time
(
nullptr
);
}
...
...
include/ascs/udp/socket.h
浏览文件 @
e00bbb93
...
...
@@ -90,7 +90,7 @@ public:
const
typename
Family
::
endpoint
&
get_peer_addr
()
const
{
return
peer_addr
;}
void
disconnect
()
{
force_shutdown
();}
v
oid
force_shutdown
()
{
show_info
(
"link:"
,
"been shutting down."
);
this
->
dispatch_strand
(
rw_strand
,
[
this
]()
{
this
->
shutdown
();}
);}
v
irtual
void
force_shutdown
()
{
shutdown
(
);}
void
graceful_shutdown
()
{
force_shutdown
();}
std
::
string
endpoint_to_string
(
const
asio
::
ip
::
udp
::
endpoint
&
ep
)
const
{
return
ep
.
address
().
to_string
()
+
':'
+
std
::
to_string
(
ep
.
port
());}
...
...
@@ -166,6 +166,8 @@ protected:
Matrix
*
get_matrix
()
{
return
matrix
;}
const
Matrix
*
get_matrix
()
const
{
return
matrix
;}
void
shutdown
(
bool
use_close
=
false
)
{
show_info
(
"link:"
,
"been shutting down."
);
this
->
dispatch_strand
(
rw_strand
,
ASCS_COPY_ALL_AND_THIS
()
{
this
->
close
(
use_close
);});}
virtual
bool
bind
(
const
typename
Family
::
endpoint
&
local_addr
)
{
return
true
;}
virtual
bool
do_start
()
...
...
@@ -224,8 +226,6 @@ private:
using
super
::
do_direct_sync_send_msg
;
#endif
void
shutdown
()
{
close
();}
virtual
void
do_recv_msg
()
{
#ifdef ASCS_PASSIVE_RECV
...
...
@@ -405,6 +405,8 @@ public:
unix_socket_base
(
asio
::
io_context
&
io_context_
)
:
super
(
io_context_
)
{}
unix_socket_base
(
Matrix
&
matrix_
)
:
super
(
matrix_
)
{}
virtual
void
force_shutdown
()
{
this
->
shutdown
(
true
);}
protected:
virtual
bool
bind
(
const
asio
::
local
::
datagram_protocol
::
endpoint
&
local_addr
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录