提交 2fb44728 编写于 作者: W wolf 提交者: youngowlf

Support asio 1.11.x

上级 f83988bd
......@@ -208,7 +208,7 @@ public:
if (cur_msg_len > ST_ASIO_MSG_BUFFER_SIZE - ST_ASIO_HEAD_LEN) //invalid msg, stop reading
return false;
raw_buff.attach(new char[cur_msg_len], cur_msg_len); assert(!raw_buff.empty());
raw_buff.assign(cur_msg_len); assert(!raw_buff.empty());
step = 1;
}
else if (1 == step) //the body been received
......@@ -235,16 +235,7 @@ public:
if (0 == step) //want the head
{
assert(raw_buff.empty());
if (bytes_transferred < ST_ASIO_HEAD_LEN)
return boost::asio::detail::default_max_transfer_size;
assert(ST_ASIO_HEAD_LEN == bytes_transferred);
size_t cur_msg_len = ST_ASIO_HEAD_N2H(head) - ST_ASIO_HEAD_LEN;
if (cur_msg_len > ST_ASIO_MSG_BUFFER_SIZE - ST_ASIO_HEAD_LEN) //invalid msg, stop reading
step = -1;
else
raw_buff.assign(cur_msg_len);
return boost::asio::detail::default_max_transfer_size;
}
else if (1 == step) //want the body
{
......
......@@ -187,7 +187,7 @@ 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 boost::asio::io_service::run, if needed, rewrite this to decide whether to continue or not
}
size_t run(boost::system::error_code& ec)
......
......@@ -197,13 +197,13 @@ public:
{
if (0 == step) //the head been received
{
assert(raw_buff.empty() && ST_ASIO_HEAD_LEN == bytes_transferred);
assert(raw_buff.empty() && ASCS_HEAD_LEN == bytes_transferred);
auto cur_msg_len = ST_ASIO_HEAD_N2H(head) - ST_ASIO_HEAD_LEN;
if (cur_msg_len > ST_ASIO_MSG_BUFFER_SIZE - ST_ASIO_HEAD_LEN) //invalid size
return false;
raw_buff.attach(new char[cur_msg_len], cur_msg_len); assert(!raw_buff.empty());
raw_buff.assign(cur_msg_len); assert(!raw_buff.empty());
step = 1;
}
else if (1 == step) //the body been received
......@@ -230,16 +230,7 @@ public:
if (0 == step) //want the head
{
assert(raw_buff.empty());
if (bytes_transferred < ST_ASIO_HEAD_LEN)
return boost::asio::detail::default_max_transfer_size;
assert(ST_ASIO_HEAD_LEN == bytes_transferred);
auto cur_msg_len = ST_ASIO_HEAD_N2H(head) - ST_ASIO_HEAD_LEN;
if (cur_msg_len > ST_ASIO_MSG_BUFFER_SIZE - ST_ASIO_HEAD_LEN) //invalid msg, stop reading
step = -1;
else
raw_buff.assign(cur_msg_len);
return boost::asio::detail::default_max_transfer_size;
}
else if (1 == step) //want the body
{
......
......@@ -185,7 +185,7 @@ 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 boost::asio::io_service::run, if needed, rewrite this to decide whether to continue or not
}
size_t run(boost::system::error_code& ec)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册