Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
anbox
提交
bc131255
A
anbox
项目概览
openeuler
/
anbox
通知
24
Star
1
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
anbox
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bc131255
编写于
8月 23, 2017
作者:
A
Alfonso Sánchez-Beato
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Avoid crashes on AdbMessageProcessor destruction
上级
5c7ac4f8
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
18 addition
and
10 deletion
+18
-10
src/anbox/qemu/adb_message_processor.cpp
src/anbox/qemu/adb_message_processor.cpp
+18
-10
未找到文件。
src/anbox/qemu/adb_message_processor.cpp
浏览文件 @
bc131255
...
@@ -34,6 +34,9 @@
...
@@ -34,6 +34,9 @@
namespace
{
namespace
{
const
unsigned
short
default_adb_client_port
{
5037
};
const
unsigned
short
default_adb_client_port
{
5037
};
// For the listening port we have to use an odd port in the 5555-5585 range so
// the host can find us on start. See
// https://developer.android.com/studio/command-line/adb.html.
const
unsigned
short
default_host_listen_port
{
5559
};
const
unsigned
short
default_host_listen_port
{
5559
};
constexpr
const
char
*
loopback_address
{
"127.0.0.1"
};
constexpr
const
char
*
loopback_address
{
"127.0.0.1"
};
const
std
::
string
accept_command
{
"accept"
};
const
std
::
string
accept_command
{
"accept"
};
...
@@ -120,8 +123,6 @@ void AdbMessageProcessor::advance_state() {
...
@@ -120,8 +123,6 @@ void AdbMessageProcessor::advance_state() {
}
}
void
AdbMessageProcessor
::
wait_for_host_connection
()
{
void
AdbMessageProcessor
::
wait_for_host_connection
()
{
INFO
(
"%p state %d"
,
this
,
state_
);
if
(
state_
!=
waiting_for_guest_accept_command
)
if
(
state_
!=
waiting_for_guest_accept_command
)
return
;
return
;
...
@@ -155,8 +156,6 @@ void AdbMessageProcessor::wait_for_host_connection() {
...
@@ -155,8 +156,6 @@ void AdbMessageProcessor::wait_for_host_connection() {
}
}
void
AdbMessageProcessor
::
on_host_connection
(
std
::
shared_ptr
<
boost
::
asio
::
basic_stream_socket
<
boost
::
asio
::
ip
::
tcp
>>
const
&
socket
)
{
void
AdbMessageProcessor
::
on_host_connection
(
std
::
shared_ptr
<
boost
::
asio
::
basic_stream_socket
<
boost
::
asio
::
ip
::
tcp
>>
const
&
socket
)
{
INFO
(
"%p state %d"
,
this
,
state_
);
host_messenger_
=
std
::
make_shared
<
network
::
TcpSocketMessenger
>
(
socket
);
host_messenger_
=
std
::
make_shared
<
network
::
TcpSocketMessenger
>
(
socket
);
// set_no_delay() reduces the latency of sending data, at the cost
// set_no_delay() reduces the latency of sending data, at the cost
...
@@ -183,11 +182,22 @@ void AdbMessageProcessor::read_next_host_message() {
...
@@ -183,11 +182,22 @@ void AdbMessageProcessor::read_next_host_message() {
void
AdbMessageProcessor
::
on_host_read_size
(
const
boost
::
system
::
error_code
&
error
,
std
::
size_t
bytes_read
)
{
void
AdbMessageProcessor
::
on_host_read_size
(
const
boost
::
system
::
error_code
&
error
,
std
::
size_t
bytes_read
)
{
if
(
error
)
{
if
(
error
)
{
INFO
(
"%p [%d] closed error %d"
,
this
,
syscall
(
SYS_gettid
),
error
.
value
());
// When AdbMessageProcessor is destroyed on program termination, the sockets
// are closed and the standing operations are canceled. But, the callback is
// still called even in that case, and the object has already been
// deleted. We detect that condition by looking at the error code and avoid
// touching *this in that case.
if
(
error
==
boost
::
system
::
errc
::
operation_canceled
)
return
;
// For other errors, we assume the connection with the host is dropped. We
// close the connection to the container's adbd, which will trigger the
// deletion of this AdbMessageProcessor instance and free resources (most
// importantly, default_host_listen_port and the lock). The standing
// connection that adbd opened can then proceed and wait for the host to be
// up again.
state_
=
closed_by_host
;
state_
=
closed_by_host
;
host_connector_
.
reset
();
messenger_
->
close
();
//messenger_.reset();
lock_
.
unlock
();
return
;
return
;
}
}
...
@@ -196,8 +206,6 @@ void AdbMessageProcessor::on_host_read_size(const boost::system::error_code &err
...
@@ -196,8 +206,6 @@ void AdbMessageProcessor::on_host_read_size(const boost::system::error_code &err
}
}
bool
AdbMessageProcessor
::
process_data
(
const
std
::
vector
<
std
::
uint8_t
>
&
data
)
{
bool
AdbMessageProcessor
::
process_data
(
const
std
::
vector
<
std
::
uint8_t
>
&
data
)
{
INFO
(
"%p state %d bytes rx %d"
,
this
,
state_
,
int
(
data
.
size
()));
if
(
state_
==
proxying_data
)
{
if
(
state_
==
proxying_data
)
{
host_messenger_
->
send
(
reinterpret_cast
<
const
char
*>
(
data
.
data
()),
host_messenger_
->
send
(
reinterpret_cast
<
const
char
*>
(
data
.
data
()),
data
.
size
());
data
.
size
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录