Skip to content

Commit 42a9697

Browse files
authored
Merge pull request #205 from evoskuil/version3
Remove connection delay in case of success code.
2 parents 5ccc464 + 8ee14b0 commit 42a9697

4 files changed

Lines changed: 7 additions & 6 deletions

File tree

include/bitcoin/network/sessions/session.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,12 @@ class BCT_API session
113113
dispatch_.delayed(delay, handler);
114114
}
115115

116-
/// Delay timing for a tight connection loop, based on configured timeout.
116+
/// Delay timing for a tight failure loop, based on configured timeout.
117117
inline asio::duration cycle_delay(const code& ec)
118118
{
119-
return (ec == error::channel_timeout || ec == error::service_stopped) ?
120-
asio::seconds(0) : settings_.connect_timeout();
119+
return (ec == error::channel_timeout || ec == error::service_stopped ||
120+
ec == error::success) ? asio::seconds(0) :
121+
settings_.connect_timeout();
121122
}
122123

123124
/// Properties.

src/sessions/session_inbound.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ void session_inbound::handle_accept(const code& ec, channel::ptr channel)
123123
return;
124124
}
125125

126-
// Start accepting again with conditional delay, regardless of error.
126+
// Start accepting with conditional delay in case of network error.
127127
dispatch_delayed(cycle_delay(ec), BIND1(start_accept, _1));
128128

129129
if (ec)

src/sessions/session_manual.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ void session_manual::handle_connect(const code& ec, channel::ptr channel,
123123

124124
if (remaining > 0)
125125
{
126-
// Retry with conditional delay, regardless of error.
126+
// Retry with conditional delay in case of network error.
127127
dispatch_delayed(cycle_delay(ec),
128128
BIND5(start_connect, _1, hostname, port, remaining, handler));
129129
return;

src/sessions/session_outbound.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ void session_outbound::handle_connect(const code& ec, channel::ptr channel)
9898
LOG_DEBUG(LOG_NETWORK)
9999
<< "Failure connecting outbound: " << ec.message();
100100

101-
// Retry with conditional delay, regardless of error.
101+
// Retry with conditional delay in case of network error.
102102
dispatch_delayed(cycle_delay(ec), BIND1(new_connection, _1));
103103
return;
104104
}

0 commit comments

Comments
 (0)