提交 dd3c0c0b 编写于 作者: W wolf

Support asio 1.11.x

上级 447bef40
......@@ -197,7 +197,13 @@ public:
{
if (0 == step) //the head been received
{
assert(!raw_buff.empty());
assert(raw_buff.empty() && ASCS_HEAD_LEN == bytes_transferred);
auto cur_msg_len = ASCS_HEAD_N2H(head) - ASCS_HEAD_LEN;
if (cur_msg_len > ASCS_MSG_BUFFER_SIZE - ASCS_HEAD_LEN) //invalid msg, stop reading
return false;
raw_buff.assign(cur_msg_len); assert(!raw_buff.empty());
step = 1;
}
else if (1 == step) //the body been received
......@@ -211,7 +217,7 @@ public:
step = 0;
}
return -1 != step;
return true;
}
//a return value of 0 indicates that the read operation is complete. a non-zero value indicates the maximum number
......@@ -224,16 +230,7 @@ public:
if (0 == step) //want the head
{
assert(raw_buff.empty());
if (bytes_transferred < ASCS_HEAD_LEN)
return asio::detail::default_max_transfer_size;
assert(ASCS_HEAD_LEN == bytes_transferred);
auto cur_msg_len = ASCS_HEAD_N2H(head) - ASCS_HEAD_LEN;
if (cur_msg_len > ASCS_MSG_BUFFER_SIZE - ASCS_HEAD_LEN) //invalid msg, stop reading
step = -1;
else
raw_buff.assign(cur_msg_len);
return asio::detail::default_max_transfer_size;
}
else if (1 == step) //want the body
{
......
......@@ -175,14 +175,14 @@ protected:
virtual bool on_exception(const std::exception& e)
{
unified_out::error_out("service pump exception: %s.", e.what());
return true; //continue this io_service::run, if needed, rewrite this to decide whether to continue or not
return true; //continue this asio::io_service::run, if needed, rewrite this to decide whether to continue or not
}
size_t run(asio::error_code& ec)
{
while (true)
{
try {return io_service::run(ec);}
try {return asio::io_service::run(ec);}
catch (const std::exception& e) {if (!on_exception(e)) return 0;}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册