]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
msgr: discard_queue now removes empty pipe queues from endpoint's map
authorGreg Farnum <gregf@hq.newdream.net>
Thu, 10 Dec 2009 22:07:25 +0000 (14:07 -0800)
committerGreg Farnum <gregf@hq.newdream.net>
Thu, 10 Dec 2009 22:33:32 +0000 (14:33 -0800)
This prevents bad pointer dereferences

src/msg/SimpleMessenger.cc

index bab1af7374fbfbb44ff79a48fce42b2cf0b8e860..558807b0dc20fc822d8588bcfa0a5f7d9946e653 100644 (file)
@@ -1184,11 +1184,16 @@ void SimpleMessenger::Pipe::discard_queue()
   bool endpoint = false;
   if (rank->local_endpoint) {
     pipe_lock.Unlock();
-    rank->local_endpoint->endpoint_lock.Lock();//to remove from pipe queue
+    xlist<Pipe *>* list_on;
+    rank->local_endpoint->endpoint_lock.Lock();//to remove from round-robin
     for (map<int, xlist<Pipe *>::item* >::iterator i = queue_items.begin();
         i != queue_items.end();
         ++i)
-      i->second->remove_myself();
+      if ((list_on = i->second->get_xlist())) { //if in round-robin
+       i->second->remove_myself(); //take off
+       if (!list_on->size()) //if round-robin queue is empty
+         rank->local_endpoint->queued_pipes.erase(i->first); //remove from map
+      }
     rank->local_endpoint->endpoint_lock.Unlock();
     endpoint = true;
     pipe_lock.Lock();