提交 eb5a6057 编写于 作者: P Phil Mesnier

bringing over changes from the dawn 2.x branch to ensure no pending fixes are lost.

上级 7a0d099d
...@@ -793,12 +793,10 @@ namespace eosio { ...@@ -793,12 +793,10 @@ namespace eosio {
} }
void connection::send_handshake( ) { void connection::send_handshake( ) {
handshake_message hello; handshake_initializer::populate(last_handshake_sent);
handshake_initializer::populate(hello); last_handshake_sent.generation = ++sent_handshake_count;
hello.generation = ++sent_handshake_count;
last_handshake_sent = hello;
fc_dlog(logger, "Sending handshake to ${ep}", ("ep", peer_addr)); fc_dlog(logger, "Sending handshake to ${ep}", ("ep", peer_addr));
enqueue(hello); enqueue(last_handshake_sent);
} }
char* connection::convert_tstamp(const tstamp& t) char* connection::convert_tstamp(const tstamp& t)
...@@ -857,7 +855,13 @@ namespace eosio { ...@@ -857,7 +855,13 @@ namespace eosio {
conn->write_depth--; conn->write_depth--;
if(ec) { if(ec) {
elog("Error sending to connection: ${i}", ("i", ec.message())); string pname = conn ? conn->peer_name() : "no connection name";
if( ec.value() != boost::asio::error::eof) {
elog("Error sending to peer ${p}: ${i}", ("p",pname)("i", ec.message()));
}
else {
ilog("connection closure detected on write to ${p}",("p",pname));
}
my_impl->close(conn); my_impl->close(conn);
return; return;
} }
...@@ -865,13 +869,19 @@ namespace eosio { ...@@ -865,13 +869,19 @@ namespace eosio {
conn->do_queue_write(); conn->do_queue_write();
} }
catch(const std::exception &ex) { catch(const std::exception &ex) {
elog("Exception in do_queue_write ${s}", ("s",ex.what())); auto conn = c.lock();
string pname = conn ? conn->peer_name() : "no connection name";
elog("Exception in do_queue_write to ${p} ${s}", ("p",pname)("s",ex.what()));
} }
catch(const fc::exception &ex) { catch(const fc::exception &ex) {
elog("Exception in do_queue_write ${s}", ("s",ex.to_string())); auto conn = c.lock();
string pname = conn ? conn->peer_name() : "no connection name";
elog("Exception in do_queue_write to ${p} ${s}", ("p",pname)("s",ex.to_string()));
} }
catch(...) { catch(...) {
elog("Exception in do_queue_write"); auto conn = c.lock();
string pname = conn ? conn->peer_name() : "no connection name";
elog("Exception in do_queue_write to ${p}", ("p",pname) );
} }
}); });
} }
...@@ -1409,26 +1419,35 @@ namespace eosio { ...@@ -1409,26 +1419,35 @@ namespace eosio {
} }
start_read_message(conn); start_read_message(conn);
} else { } else {
elog( "Error reading message from connection: ${m}",( "m", ec.message() ) ); auto pname = conn->peer_name();
if (ec.value() != boost::asio::error::eof) {
elog( "Error reading message from ${p}: ${m}",("p",pname)( "m", ec.message() ) );
} else {
ilog( "Peer ${p} closed connection",("p",pname) );
}
close( conn ); close( conn );
} }
} }
catch(const std::exception &ex) { catch(const std::exception &ex) {
elog("Exception in handling read data ${s}", ("s",ex.what())); string pname = conn ? conn->peer_name() : "no connection name";
elog("Exception in handling read data from ${p} ${s}",("p",pname)("s",ex.what()));
close( conn ); close( conn );
} }
catch(const fc::exception &ex) { catch(const fc::exception &ex) {
elog("Exception in handling read data ${s}", ("s",ex.to_string())); string pname = conn ? conn->peer_name() : "no connection name";
elog("Exception in handling read data ${s}", ("p",pname)("s",ex.to_string()));
close( conn ); close( conn );
} }
catch (...) { catch (...) {
elog( "Undefined exception hanlding the read data from connection: ${m}",( "m", ec.message() ) ); string pname = conn ? conn->peer_name() : "no connection name";
elog( "Undefined exception hanlding the read data from connection ${p}",( "p",pname));
close( conn ); close( conn );
} }
} }
); );
} catch (...) { } catch (...) {
elog( "Undefined exception handling reading" ); string pname = conn ? conn->peer_name() : "no connection name";
elog( "Undefined exception handling reading ${p}",("p",pname) );
close( conn ); close( conn );
} }
} }
...@@ -1620,6 +1639,7 @@ namespace eosio { ...@@ -1620,6 +1639,7 @@ namespace eosio {
void net_plugin_impl::handle_message( connection_ptr c, const go_away_message &msg ) { void net_plugin_impl::handle_message( connection_ptr c, const go_away_message &msg ) {
string rsn = reason_str( msg.reason ); string rsn = reason_str( msg.reason );
ilog( "received a go away message, reason = ${r}",("r",rsn));
c->no_retry = msg.reason; c->no_retry = msg.reason;
if(msg.reason == go_away_reason::duplicate ) { if(msg.reason == go_away_reason::duplicate ) {
c->node_id = msg.node_id; c->node_id = msg.node_id;
...@@ -2300,7 +2320,7 @@ namespace eosio { ...@@ -2300,7 +2320,7 @@ namespace eosio {
// If we couldn't sign, don't send a token. // If we couldn't sign, don't send a token.
if(hello.sig == chain::signature_type()) if(hello.sig == chain::signature_type())
hello.token = sha256(); hello.token = sha256();
hello.p2p_address = my_impl->p2p_address; hello.p2p_address = my_impl->p2p_address + " - " + hello.node_id.str().substr(0,7);
#if defined( __APPLE__ ) #if defined( __APPLE__ )
hello.os = "osx"; hello.os = "osx";
#elif defined( __linux__ ) #elif defined( __linux__ )
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册