]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/async: avoid requeue racing with handle_write
authorHaomai Wang <haomai@xsky.com>
Sat, 27 May 2017 01:59:11 +0000 (09:59 +0800)
committerHaomai Wang <haomai@xsky.com>
Sat, 27 May 2017 02:44:24 +0000 (10:44 +0800)
when the thread is calling AsyncConnection::handle_write, another thread may
replace it and requeue all messages. Because we remove the write_lock
protection for handle_write caller, it may happen sent racing with out_q

Fix: http://tracker.ceph.com/issues/20093

Signed-off-by: Haomai Wang <haomai@xsky.com>
src/msg/async/AsyncConnection.cc

index 585e0b8083537c935f8795cc96c37f666370386a..7cc6fe97154278ee15cc0c99dc58174826dc3c36 100644 (file)
@@ -1679,7 +1679,6 @@ ssize_t AsyncConnection::handle_connect_msg(ceph_msg_connect &connect, bufferlis
       existing->delay_state->flush();
       assert(!delay_state);
     }
-    existing->requeue_sent();
     existing->reset_recv_state();
 
     auto temp_cs = std::move(cs);
@@ -1706,8 +1705,11 @@ ssize_t AsyncConnection::handle_connect_msg(ceph_msg_connect &connect, bufferlis
       // we need to delete time event in original thread
       {
         std::lock_guard<std::mutex> l(existing->lock);
+        existing->write_lock.lock();
+        existing->requeue_sent();
         existing->outcoming_bl.clear();
         existing->open_write = false;
+        existing->write_lock.unlock();
         if (existing->state == STATE_NONE) {
           existing->shutdown_socket();
           existing->cs = std::move(cs);