]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
msg/async/Protocol*: fix mark_down vs accept race
authorSage Weil <sage@redhat.com>
Tue, 8 Jan 2019 13:13:13 +0000 (07:13 -0600)
committerSage Weil <sage@redhat.com>
Tue, 8 Jan 2019 13:13:23 +0000 (07:13 -0600)
If we mark_down the connection while we have the lock dropped the state
maybe CLOSED when we retake it.  Bail out if that happens instead of
continuing to process the connection and eventually running into an
assertion on can_write.

Fixes: http://tracker.ceph.com/issues/36497
Signed-off-by: Sage Weil <sage@redhat.com>
src/msg/async/ProtocolV1.cc
src/msg/async/ProtocolV2.cc

index ab4b526105f1ca5d82a285adc34e2e28e747d8c4..0d71148ffbd970da80679fd46e46d4db0481e28b 100644 (file)
@@ -1933,6 +1933,13 @@ CtPtr ProtocolV1::handle_connect_message_2() {
           need_challenge ? &authorizer_challenge : nullptr) ||
       !authorizer_valid) {
     connection->lock.lock();
+    if (state != ACCEPTING_WAIT_CONNECT_MSG_AUTH) {
+      ldout(cct, 1) << __func__
+                   << " state changed while accept, it must be mark_down"
+                   << dendl;
+      ceph_assert(state == CLOSED);
+      return _fault();
+    }
 
     if (need_challenge && !had_challenge && authorizer_challenge) {
       ldout(cct, 10) << __func__ << ": challenging authorizer" << dendl;
index 99b424e6dbc3c1aea9a0d4704b64d8aa695966e3..526545d6ea8063bded66e48ca698f1d4093cbed2 100644 (file)
@@ -1980,6 +1980,13 @@ CtPtr ProtocolV2::handle_connect_message_2() {
           need_challenge ? &authorizer_challenge : nullptr) ||
       !authorizer_valid) {
     connection->lock.lock();
+    if (state != ACCEPTING_WAIT_CONNECT_MSG_AUTH) {
+      ldout(cct, 1) << __func__
+                   << " state changed while accept, it must be mark_down"
+                   << dendl;
+      ceph_assert(state == CLOSED);
+      return _fault();
+    }
 
     if (need_challenge && !had_challenge && authorizer_challenge) {
       ldout(cct, 10) << __func__ << ": challenging authorizer" << dendl;