]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/async: add comments for commit 294c41f18adada6ab. 28667/head
authorJianpeng Ma <jianpeng.ma@intel.com>
Mon, 24 Jun 2019 12:24:36 +0000 (20:24 +0800)
committerJianpeng Ma <jianpeng.ma@intel.com>
Mon, 24 Jun 2019 12:24:36 +0000 (20:24 +0800)
Consider this case:
    send-thread                                 msg-work
                                            write_event()
                                             r = write_message()
connection->write_lock.lock()
if (.. && !write_in_progress) {
  write_in_progress = true;
  add external_event
}
connection->write_lock.unlock()
                                          connection->write_lock.lock()
                                          if (r > 0)
                                            break;
                                          } while ();
                                          write_in_progress = false;

For this case, we don't add external_event and in write_event we don't
check out_q whether empty rather than break.
This make msg-work never wake up again.
Fortunately, if write_message() > 0, in AsyncConnection::_try_send will
add an EVENT_WRITEABLE to wake up msg-work. So bug can't occur.

I add comment to descript this and hope get the better method to fix
this.

Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
src/msg/async/ProtocolV1.cc
src/msg/async/ProtocolV2.cc

index b410a2e6b79e9da17d80668503cf8065dce4204b..1708b0c211e6398e6075c94c220e88f2186da853 100644 (file)
@@ -346,8 +346,11 @@ void ProtocolV1::write_event() {
       } else if (r < 0) {
         ldout(cct, 1) << __func__ << " send msg failed" << dendl;
         break;
-      } else if (r > 0)
-        break;
+      } else if (r > 0) {
+       // Outbound message in-progress, thread will be re-awoken
+       // when the outbound socket is writeable again
+       break;
+      }
     } while (can_write == WriteStatus::CANWRITE);
     write_in_progress = false;
     connection->write_lock.unlock();
index 77ab2dfd955594c8a63d5dac6686d9de8b0df93b..5eb3cf883dad352a796538ec9cb6c87a1bed010c 100644 (file)
@@ -626,8 +626,11 @@ void ProtocolV2::write_event() {
       } else if (r < 0) {
         ldout(cct, 1) << __func__ << " send msg failed" << dendl;
         break;
-      } else if (r > 0)
+      } else if (r > 0) {
+       // Outbound message in-progress, thread will be re-awoken
+       // when the outbound socket is writeable again
         break;
+      }
     } while (can_write);
     write_in_progress = false;