Bug 1257314 - Properly lock in IPC PeekMessages. r=dvander
authorBenoit Girard <b56girard@gmail.com>
Wed, 16 Mar 2016 17:15:38 -0400
changeset 341384 186064e556caa51a3cb804e43ff7356b36e3e2f2
parent 341377 fd6c1f7f3e4eef20b5f08106b8ac73599bdc8c88
child 341385 bea1d2b7531368d5b3a5228b430c3caa685a43d1
child 341643 b07ea38af92661afce4746e51c28c2177c7f051e
push id13207
push userbmo:mh+mozilla@glandium.org
push dateThu, 17 Mar 2016 00:01:57 +0000
reviewersdvander
bugs1257314
milestone48.0a1
Bug 1257314 - Properly lock in IPC PeekMessages. r=dvander MozReview-Commit-ID: 8iUVhiN9Ksk
ipc/glue/MessageChannel.cpp
--- a/ipc/glue/MessageChannel.cpp
+++ b/ipc/glue/MessageChannel.cpp
@@ -971,17 +971,20 @@ MessageChannel::OnMessageReceivedFromLin
             // If we compressed away the previous message, we'll re-use
             // its pending task.
             mWorkerLoop->PostTask(FROM_HERE, new DequeueTask(mDequeueOneTask));
         }
     }
 }
 
 void
-MessageChannel::PeekMessages(msgid_t aMsgId, mozilla::function<void(const Message& aMsg)> aInvoke) {
+MessageChannel::PeekMessages(msgid_t aMsgId, mozilla::function<void(const Message& aMsg)> aInvoke)
+{
+    MonitorAutoLock lock(*mMonitor);
+
     for (MessageQueue::iterator it = mPending.begin(); it != mPending.end(); it++) {
         Message &msg = *it;
 
         if (msg.type() == aMsgId) {
           aInvoke(msg);
         }
     }
 }