From 15f05d407adb09e8af272fbb03b58ae1f31b83fa Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Thu, 10 Dec 2009 14:07:25 -0800 Subject: [PATCH] msgr: discard_queue now removes empty pipe queues from endpoint's map This prevents bad pointer dereferences --- src/msg/SimpleMessenger.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/msg/SimpleMessenger.cc b/src/msg/SimpleMessenger.cc index bab1af7374fbf..558807b0dc20f 100644 --- a/src/msg/SimpleMessenger.cc +++ b/src/msg/SimpleMessenger.cc @@ -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* list_on; + rank->local_endpoint->endpoint_lock.Lock();//to remove from round-robin for (map::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(); -- 2.39.5