summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmir Taaki <genjix@riseup.net>2014-04-08 18:22:09 (GMT)
committer Amir Taaki <genjix@riseup.net>2014-04-08 18:22:09 (GMT)
commit116f4ffe87dd0cfd9795873e81d3d3f0f8b95709 (patch)
tree0884558b5eac2214c4d17c2e392fac83dc87e59a
parente31ea45ac02880841e9c0a8d1a765a468d211bd3 (diff)
don't change state until after ec is checked.
-rw-r--r--src/network/protocol.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/network/protocol.cpp b/src/network/protocol.cpp
index 5f41938..8b2923f 100644
--- a/src/network/protocol.cpp
+++ b/src/network/protocol.cpp
@@ -397,8 +397,6 @@ void protocol::handle_connect(
const network_address_type& address, slot_index slot)
{
BITCOIN_ASSERT(connect_states_[slot] == connect_state::connecting);
- modify_slot(slot, connect_state::established);
- BITCOIN_ASSERT(connections_.size() <= max_outbound_);
if (ec)
{
log_warning(LOG_PROTOCOL) << "Unable to connect to "
@@ -410,6 +408,8 @@ void protocol::handle_connect(
try_connect_once(slot);
return;
}
+ modify_slot(slot, connect_state::established);
+ BITCOIN_ASSERT(connections_.size() <= max_outbound_);
connections_.push_back({address, node});
log_info(LOG_PROTOCOL) << "Connected to "
<< pretty(address.ip) << ":" << address.port