Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
youngwolf
ascs
提交
aebb16ff
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,体验更适合开发者的 AI 搜索 >>
提交
aebb16ff
编写于
1月 16, 2019
作者:
Y
yang li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix: if give up connecting, ascs::socket::started() still returns true.
Fix repetitive binding.
上级
eb93b242
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
43 addition
and
20 deletion
+43
-20
include/ascs/config.h
include/ascs/config.h
+2
-0
include/ascs/tcp/client.h
include/ascs/tcp/client.h
+14
-6
include/ascs/tcp/client_socket.h
include/ascs/tcp/client_socket.h
+5
-4
include/ascs/tcp/socket.h
include/ascs/tcp/socket.h
+6
-2
include/ascs/udp/socket.h
include/ascs/udp/socket.h
+2
-2
include/ascs/udp/socket_service.h
include/ascs/udp/socket_service.h
+14
-6
未找到文件。
include/ascs/config.h
浏览文件 @
aebb16ff
...
...
@@ -21,6 +21,7 @@
* 4. since 1.1.5 until 1.2, SSL doesn't support heartbeat because SSL doesn't support OOB data.
* 5. with old openssl (at least 0.9.7), ssl::client_socket_base and ssl_server_socket_base are not reusable, I'm not sure in which version,
* they became available, seems it's 1.0.0.
* 6. since 1.0.0 until 1.3.0, async_write and async_read are not mutexed on the same socket, which is a violation of asio threading model.
*
* 2016.9.25 version 1.0.0
* Based on st_asio_wrapper 1.2.0.
...
...
@@ -453,6 +454,7 @@
* HIGHLIGHT:
*
* FIX:
* If give up connecting (prepare_reconnect returns -1 or call close_reconnect), ascs::socket::started() still returns true (should be false).
*
* ENHANCEMENTS:
* Expose server_base's acceptor via next_layer().
...
...
include/ascs/tcp/client.h
浏览文件 @
aebb16ff
...
...
@@ -48,12 +48,20 @@ public:
{
auto
socket_ptr
(
this
->
create_object
());
if
(
!
socket_ptr
)
return
typename
Pool
::
object_type
();
else
{
socket_ptr
->
set_server_addr
(
port
,
ip
);
return
this
->
add_socket
(
socket_ptr
,
false
)
?
socket_ptr
:
typename
Pool
::
object_type
();
}
return
socket_ptr
;
socket_ptr
->
set_server_addr
(
port
,
ip
);
return
this
->
add_socket
(
socket_ptr
,
false
)
?
socket_ptr
:
typename
Pool
::
object_type
();
}
typename
Pool
::
object_type
add_socket
(
unsigned
short
port
,
unsigned
short
local_port
,
const
std
::
string
&
ip
=
ASCS_SERVER_IP
,
const
std
::
string
&
local_ip
=
std
::
string
())
{
auto
socket_ptr
(
this
->
create_object
());
if
(
!
socket_ptr
)
return
socket_ptr
;
socket_ptr
->
set_server_addr
(
port
,
ip
);
socket_ptr
->
set_local_addr
(
local_port
,
local_ip
);
return
this
->
add_socket
(
socket_ptr
,
false
)
?
socket_ptr
:
typename
Pool
::
object_type
();
}
///////////////////////////////////////////////////
...
...
include/ascs/tcp/client_socket.h
浏览文件 @
aebb16ff
...
...
@@ -95,8 +95,8 @@ protected:
}
}
lowest_object
.
bind
(
local_addr
,
ec
);
assert
(
!
ec
);
if
(
ec
)
lowest_object
.
bind
(
local_addr
,
ec
);
if
(
ec
&&
asio
::
error
::
invalid_argument
!=
ec
)
{
unified_out
::
error_out
(
"cannot bind socket: %s"
,
ec
.
message
().
data
());
return
false
;
...
...
@@ -111,7 +111,7 @@ protected:
{
if
(
!
ec
)
//already started, so cannot call start()
super
::
do_start
();
else
if
(
need_reconnect
)
else
prepare_next_reconnect
(
ec
);
}
...
...
@@ -144,7 +144,7 @@ protected:
private:
bool
prepare_next_reconnect
(
const
asio
::
error_code
&
ec
)
{
if
(
this
->
started
()
&&
!
this
->
stopped
())
if
(
need_reconnect
&&
this
->
started
()
&&
!
this
->
stopped
())
{
#ifdef _WIN32
if
(
asio
::
error
::
connection_refused
!=
ec
&&
asio
::
error
::
network_unreachable
!=
ec
&&
asio
::
error
::
timed_out
!=
ec
)
...
...
@@ -162,6 +162,7 @@ private:
}
}
super
::
force_shutdown
();
return
false
;
}
...
...
include/ascs/tcp/socket.h
浏览文件 @
aebb16ff
...
...
@@ -185,10 +185,14 @@ protected:
//DO NOT hold msg_can for future using, just swap its content with your own container in this virtual function.
virtual
void
on_send_error
(
const
asio
::
error_code
&
ec
,
list
<
typename
super
::
in_msg
>&
msg_can
)
{
unified_out
::
error_out
(
"send msg error (%d %s)"
,
ec
.
value
(),
ec
.
message
().
data
());}
virtual
void
on_close
()
{
#ifdef ASCS_SYNC_SEND
virtual
void
on_close
()
{
ascs
::
do_something_to_all
(
last_send_msg
,
[](
typename
super
::
in_msg
&
msg
)
{
if
(
msg
.
p
)
msg
.
p
->
set_value
(
sync_call_result
::
NOT_APPLICABLE
);});
super
::
on_close
();}
ascs
::
do_something_to_all
(
last_send_msg
,
[](
typename
super
::
in_msg
&
msg
)
{
if
(
msg
.
p
)
msg
.
p
->
set_value
(
sync_call_result
::
NOT_APPLICABLE
);});
#endif
status
=
link_status
::
BROKEN
;
super
::
on_close
();
}
virtual
void
on_connect
()
{}
//msg can not be unpacked
...
...
include/ascs/udp/socket.h
浏览文件 @
aebb16ff
...
...
@@ -136,8 +136,8 @@ protected:
if
(
0
!=
local_addr
.
port
()
||
!
local_addr
.
address
().
is_unspecified
())
{
asio
::
error_code
ec
;
lowest_object
.
bind
(
local_addr
,
ec
);
assert
(
!
ec
);
if
(
ec
)
lowest_object
.
bind
(
local_addr
,
ec
);
if
(
ec
&&
asio
::
error
::
invalid_argument
!=
ec
)
{
unified_out
::
error_out
(
"cannot bind socket: %s"
,
ec
.
message
().
data
());
return
(
has_bound
=
false
);
...
...
include/ascs/udp/socket_service.h
浏览文件 @
aebb16ff
...
...
@@ -33,12 +33,20 @@ public:
{
auto
socket_ptr
(
this
->
create_object
());
if
(
!
socket_ptr
)
return
typename
Pool
::
object_type
();
else
{
socket_ptr
->
set_local_addr
(
port
,
ip
);
return
this
->
add_socket
(
socket_ptr
)
?
socket_ptr
:
typename
Pool
::
object_type
();
}
return
socket_ptr
;
socket_ptr
->
set_local_addr
(
port
,
ip
);
return
this
->
add_socket
(
socket_ptr
)
?
socket_ptr
:
typename
Pool
::
object_type
();
}
typename
Pool
::
object_type
add_socket
(
unsigned
short
port
,
unsigned
short
peer_port
,
const
std
::
string
&
ip
=
std
::
string
(),
const
std
::
string
&
peer_ip
=
std
::
string
())
{
auto
socket_ptr
(
this
->
create_object
());
if
(
!
socket_ptr
)
return
socket_ptr
;
socket_ptr
->
set_local_addr
(
port
,
ip
);
socket_ptr
->
set_peer_addr
(
peer_port
,
peer_ip
);
return
this
->
add_socket
(
socket_ptr
)
?
socket_ptr
:
typename
Pool
::
object_type
();
}
//functions with a socket_ptr parameter will remove the link from object pool first, then call corresponding function
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录