Skip to content

Commit

Permalink
Merge pull request #82 from cyshi/baidu_master
Browse files Browse the repository at this point in the history
format code style
  • Loading branch information
cyshi committed Mar 28, 2016
2 parents 5d5af8e + 15f0387 commit dc55b40
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/sofa/pbrpc/rpc_byte_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,14 @@ class RpcByteStream : public sofa::pbrpc::enable_shared_from_this<RpcByteStream>
}
}

void on_connect_timeout(const boost::system::error_code& error) {
if (_status != STATUS_CONNECTING) {
void on_connect_timeout(const boost::system::error_code& error)
{
if (_status != STATUS_CONNECTING)
{
return;
}
if (error == boost::asio::error::operation_aborted) {
if (error == boost::asio::error::operation_aborted)
{
return;
}
close("connect timeout");
Expand All @@ -106,7 +109,8 @@ class RpcByteStream : public sofa::pbrpc::enable_shared_from_this<RpcByteStream>
_status = STATUS_CONNECTING;
_socket.async_connect(_remote_endpoint,
boost::bind(&RpcByteStream::on_connect, shared_from_this(), _1));
if (_connect_timeout > 0) {
if (_connect_timeout > 0)
{
_timer.expires_from_now(boost::posix_time::milliseconds(_connect_timeout));
_timer.async_wait(boost::bind(&RpcByteStream::on_connect_timeout, shared_from_this(), _1));
}
Expand Down Expand Up @@ -242,11 +246,13 @@ class RpcByteStream : public sofa::pbrpc::enable_shared_from_this<RpcByteStream>
return _last_rw_ticks;
}

void set_connect_timeout(int64 timeout) {
void set_connect_timeout(int64 timeout)
{
_connect_timeout = timeout;
}

int64 connect_timeout() {
int64 connect_timeout()
{
return _connect_timeout;
}

Expand Down Expand Up @@ -303,7 +309,8 @@ class RpcByteStream : public sofa::pbrpc::enable_shared_from_this<RpcByteStream>
SOFA_PBRPC_FUNCTION_TRACE;

//Maybe already timeout
if (_status != STATUS_CONNECTING) {
if (_status != STATUS_CONNECTING)
{
return;
}

Expand Down

0 comments on commit dc55b40

Please sign in to comment.