diff --git a/ipc/glue/MessageChannel.cpp b/ipc/glue/MessageChannel.cpp index 8a8a4bbe5fc1..cdd6a0cbff54 100644 --- a/ipc/glue/MessageChannel.cpp +++ b/ipc/glue/MessageChannel.cpp @@ -920,15 +920,31 @@ MessageChannel::Send(Message* aMsg, Message* aReply) { // Don't allow sending CPOWs while we're dispatching a sync message. // If you want to do that, use sendRpcMessage instead. + IPC_LOG("Prio forbids send"); + return false; + } + + if (mCurrentTransaction && + (DispatchingSyncMessagePriority() == IPC::Message::PRIORITY_URGENT || + DispatchingAsyncMessagePriority() == IPC::Message::PRIORITY_URGENT)) + { + // Generally only the parent dispatches urgent messages. And the only + // sync messages it can send are high-priority. Mainly we want to ensure + // here that we don't return false for non-CPOW messages. + MOZ_ASSERT(msg->priority() == IPC::Message::PRIORITY_HIGH); return false; } if (mCurrentTransaction && (msg->priority() < DispatchingSyncMessagePriority() || - mAwaitingSyncReplyPriority > msg->priority())) + msg->priority() < AwaitingSyncReplyPriority())) { + MOZ_ASSERT(DispatchingSyncMessage() || DispatchingAsyncMessage()); + IPC_LOG("Cancel from Send"); + CancelMessage *cancel = new CancelMessage(); + cancel->set_transaction_id(mCurrentTransaction); + mLink->SendMessage(cancel); CancelCurrentTransactionInternal(); - mLink->SendMessage(new CancelMessage()); } IPC_ASSERT(msg->is_sync(), "can only Send() sync messages here");