diff --git a/ipc/glue/MessageChannel.cpp b/ipc/glue/MessageChannel.cpp index 14d99a2db82b..5681468796ec 100644 --- a/ipc/glue/MessageChannel.cpp +++ b/ipc/glue/MessageChannel.cpp @@ -704,23 +704,6 @@ MessageChannel::Send(Message* aMsg, Message* aReply) IPC_ASSERT(mAwaitingSyncReplyPriority <= aMsg->priority(), "nested sync message sends must be of increasing priority"); - AutoSetValue replies(mAwaitingSyncReply, true); - AutoSetValue prio(mAwaitingSyncReplyPriority, aMsg->priority()); - AutoEnterTransaction transact(this); - aMsg->set_transaction_id(mCurrentTransaction); - - if (!SendAndWait(aMsg, aReply)) - return false; - - NS_ABORT_IF_FALSE(aReply->is_sync(), "reply is not sync"); - return true; -} - -bool -MessageChannel::SendAndWait(Message* aMsg, Message* aReply) -{ - mMonitor->AssertCurrentThreadOwns(); - nsAutoPtr msg(aMsg); if (!Connected()) { @@ -733,6 +716,13 @@ MessageChannel::SendAndWait(Message* aMsg, Message* aReply) DebugOnly replySeqno = msg->seqno(); DebugOnly replyType = msg->type() + 1; + AutoSetValue replies(mAwaitingSyncReply, true); + AutoSetValue prio(mAwaitingSyncReplyPriority, msg->priority()); + AutoEnterTransaction transact(this, msg->seqno()); + + int32_t transaction = mCurrentTransaction; + msg->set_transaction_id(transaction); + mLink->SendMessage(msg.forget()); while (true) { @@ -770,6 +760,7 @@ MessageChannel::SendAndWait(Message* aMsg, Message* aReply) MOZ_ASSERT(mRecvd->type() == replyType, "wrong reply type"); MOZ_ASSERT(mRecvd->seqno() == replySeqno); + MOZ_ASSERT(mRecvd->is_sync()); *aReply = Move(*mRecvd); mRecvd = nullptr; diff --git a/ipc/glue/MessageChannel.h b/ipc/glue/MessageChannel.h index af770a7b5106..323e0450bc19 100644 --- a/ipc/glue/MessageChannel.h +++ b/ipc/glue/MessageChannel.h @@ -211,20 +211,6 @@ class MessageChannel : HasResultCodes // Send OnChannelConnected notification to listeners. void DispatchOnChannelConnected(); - // Any protocol that requires blocking until a reply arrives, will send its - // outgoing message through this function. Currently, two protocols do this: - // - // sync, which can only initiate messages from child to parent. - // urgent, which can only initiate messages from parent to child. - // - // SendAndWait() expects that the worker thread owns the monitor, and that - // the message has been prepared to be sent over the link. It returns as - // soon as a reply has been received, or an error has occurred. - // - // Note that while the child is blocked waiting for a sync reply, it can wake - // up to process urgent calls from the parent. - bool SendAndWait(Message* aMsg, Message* aReply); - bool InterruptEventOccurred(); bool ProcessPendingRequest(const Message &aUrgent); @@ -501,13 +487,13 @@ class MessageChannel : HasResultCodes class AutoEnterTransaction { public: - explicit AutoEnterTransaction(MessageChannel *aChan) + explicit AutoEnterTransaction(MessageChannel *aChan, int32_t aMsgSeqno) : mChan(aChan), mOldTransaction(mChan->mCurrentTransaction) { mChan->mMonitor->AssertCurrentThreadOwns(); if (mChan->mCurrentTransaction == 0) - mChan->mCurrentTransaction = mChan->NextSeqno(); + mChan->mCurrentTransaction = aMsgSeqno; } explicit AutoEnterTransaction(MessageChannel *aChan, const Message &aMessage) : mChan(aChan),