Skip to content

Commit

Permalink
msg: use timeout when initiating connection
Browse files Browse the repository at this point in the history
There's a timer that enforces a connection timeout but it isn't scoped
properly. It's started only after the ``connect`` request completes.
Because of that, connections can hang in STATE_CONNECTING_RE state
indefinitely if the "connect" operation doesn't complete.

This change will start the timer when entering the STATE_CONNECTING
state.

Signed-off-by: Lucian Petrut <[email protected]>
  • Loading branch information
petrutlucian94 committed Nov 18, 2020
1 parent d48c6c4 commit ceda75a
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/msg/async/AsyncConnection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,10 @@ void AsyncConnection::process() {
// clear timer (if any) since we are connecting/re-connecting
if (last_tick_id) {
center->delete_time_event(last_tick_id);
last_tick_id = 0;
}
last_connect_started = ceph::coarse_mono_clock::now();
last_tick_id = center->create_time_event(
connect_timeout_us, tick_handler);

if (cs) {
center->delete_file_event(cs.fd(), EVENT_READABLE | EVENT_WRITABLE);
Expand Down Expand Up @@ -432,11 +434,6 @@ void AsyncConnection::process() {
ldout(async_msgr->cct, 10)
<< __func__ << " connect successfully, ready to send banner" << dendl;
state = STATE_CONNECTION_ESTABLISHED;
ceph_assert(last_tick_id == 0);
// exclude TCP nonblock connect time
last_connect_started = ceph::coarse_mono_clock::now();
last_tick_id = center->create_time_event(
connect_timeout_us, tick_handler);
break;
}

Expand Down

0 comments on commit ceda75a

Please sign in to comment.