From 9cb4b0e9d5564d6458f2f090755e4e8920fa72de Mon Sep 17 00:00:00 2001 From: Bill McCloskey Date: Fri, 22 Jan 2016 18:04:08 -0800 Subject: [PATCH] Bug 1240985 - Always enqueue OnMaybeDequeueOne task when receiving a message (r=dvander) --- ipc/glue/MessageChannel.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/ipc/glue/MessageChannel.cpp b/ipc/glue/MessageChannel.cpp index 4bf5c8137301..5940af00f9ca 100644 --- a/ipc/glue/MessageChannel.cpp +++ b/ipc/glue/MessageChannel.cpp @@ -740,10 +740,18 @@ MessageChannel::OnMessageReceivedFromLink(const Message& aMsg) } } + bool wakeUpSyncSend = AwaitingSyncReply() && !ShouldDeferMessage(aMsg); + bool shouldWakeUp = AwaitingInterruptReply() || - (AwaitingSyncReply() && !ShouldDeferMessage(aMsg)) || + wakeUpSyncSend || AwaitingIncomingMessage(); + // Although we usually don't need to post an OnMaybeDequeueOne task if + // shouldWakeUp is true, it's easier to post anyway than to have to + // guarantee that every Send call processes everything it's supposed to + // before returning. + bool shouldPostTask = !shouldWakeUp || wakeUpSyncSend; + IPC_LOG("Receive on link thread; seqno=%d, xid=%d, shouldWakeUp=%d", aMsg.seqno(), aMsg.transaction_id(), shouldWakeUp); @@ -773,10 +781,9 @@ MessageChannel::OnMessageReceivedFromLink(const Message& aMsg) if (shouldWakeUp) { NotifyWorkerThread(); - } else { - // Worker thread is either not blocked on a reply, or this is an - // incoming Interrupt that raced with outgoing sync, and needs to be - // deferred to a later event-loop iteration. + } + + if (shouldPostTask) { if (!compress) { // If we compressed away the previous message, we'll re-use // its pending task. @@ -788,7 +795,7 @@ MessageChannel::OnMessageReceivedFromLink(const Message& aMsg) void MessageChannel::ProcessPendingRequests(int transaction, int prio) { - IPC_LOG("ProcessPendingRequests"); + IPC_LOG("ProcessPendingRequests for seqno=%d, xid=%d", seqno, transaction); // Loop until there aren't any more priority messages to process. for (;;) {