]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
msg: use timeout when initiating connection 38161/head
authorLucian Petrut <lpetrut@cloudbasesolutions.com>
Tue, 17 Nov 2020 13:12:59 +0000 (13:12 +0000)
committerLucian Petrut <lpetrut@cloudbasesolutions.com>
Wed, 18 Nov 2020 13:33:37 +0000 (13:33 +0000)
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 <lpetrut@cloudbasesolutions.com>
src/msg/async/AsyncConnection.cc

index 8b2a4a2b7b3a8783eb1c8749cdc79684ce24f68e..5769c580e0742f1a513877582a6aac1beb28ad34 100644 (file)
@@ -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);
@@ -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;
     }