]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
msgr: don't queue message on closed pipe
authorSage Weil <sage@inktank.com>
Sun, 23 Dec 2012 17:19:05 +0000 (09:19 -0800)
committerSage Weil <sage@inktank.com>
Sat, 19 Jan 2013 00:17:50 +0000 (16:17 -0800)
If we have a con that refs a pipe but it is closed, don't use it.  If
the ref is still there, it is only because we are racing with fault()
and it is about to (or just was) be detached.  Either way,

Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit 6339c5d43974f4b495f15d199e01a141e74235f5)

src/msg/Pipe.h
src/msg/SimpleMessenger.cc

index 4f6fc22b9d68bee3e3b19e0579434dd5c25cc36a..dfb926734a55716f0e95d6d11c954162cd191911 100644 (file)
@@ -243,11 +243,6 @@ class DispatchQueue;
     }
     void stop();
 
-    void send(Message *m) {
-      pipe_lock.Lock();
-      _send(m);
-      pipe_lock.Unlock();
-    }
     void _send(Message *m) {
       out_q[m->get_priority()].push_back(m);
       cond.Signal();
index a6e2f984505919c5da08afb673bcde38c844bf81..3d2eb79b37656836e14db64518aa4fabd04cd52f 100644 (file)
@@ -397,10 +397,18 @@ void SimpleMessenger::submit_message(Message *m, Connection *con,
       return;
     }
     if (pipe) {
-      ldout(cct,20) << "submit_message " << *m << " remote, " << dest_addr << ", have pipe." << dendl;
-      pipe->send(m);
+      pipe->pipe_lock.Lock();
+      if (pipe->state != Pipe::STATE_CLOSED) {
+       ldout(cct,20) << "submit_message " << *m << " remote, " << dest_addr << ", have pipe." << dendl;
+       pipe->_send(m);
+       pipe->pipe_lock.Unlock();
+       pipe->put();
+       return;
+      }
+      pipe->pipe_lock.Unlock();
       pipe->put();
-      return;
+      ldout(cct,20) << "submit_message " << *m << " remote, " << dest_addr
+                   << ", had pipe " << pipe << ", but it closed." << dendl;
     }
   }