Bug 947632 - Assert that we don't sendSyncMessage while processing a CPOW request (r=dvander)

This commit is contained in:
Bill McCloskey 2013-12-14 15:50:22 -08:00
Родитель 69acf97733
Коммит 735523245e
2 изменённых файлов: 15 добавлений и 1 удалений

Просмотреть файл

@ -57,6 +57,7 @@ MessageChannel::MessageChannel(MessageListener *aListener)
mPendingRPCReplies(0),
mCurrentRPCTransaction(0),
mDispatchingSyncMessage(false),
mDispatchingUrgentMessageCount(0),
mRemoteStackDepthGuess(false),
mSawInterruptOutMsg(false)
{
@ -416,6 +417,7 @@ MessageChannel::Send(Message* aMsg, Message* aReply)
IPC_ASSERT(aMsg->is_sync(), "can only Send() sync messages here");
IPC_ASSERT(!DispatchingSyncMessage(), "violation of sync handler invariant");
IPC_ASSERT(!DispatchingUrgentMessage(), "sync messages forbidden while handling urgent message");
IPC_ASSERT(!AwaitingSyncReply(), "nested sync messages are not supported");
AutoEnterPendingReply replies(mPendingSyncReplies);
@ -937,7 +939,11 @@ MessageChannel::DispatchUrgentMessage(const Message& aMsg)
Message *reply = nullptr;
if (!MaybeHandleError(mListener->OnCallReceived(aMsg, reply), "DispatchUrgentMessage")) {
mDispatchingUrgentMessageCount++;
Result rv = mListener->OnCallReceived(aMsg, reply);
mDispatchingUrgentMessageCount--;
if (!MaybeHandleError(rv, "DispatchUrgentMessage")) {
delete reply;
reply = new Message();
reply->set_urgent();

Просмотреть файл

@ -384,6 +384,11 @@ class MessageChannel : HasResultCodes
return mDispatchingSyncMessage;
}
// Returns true if we're dispatching an urgent message's callback.
bool DispatchingUrgentMessage() const {
return mDispatchingUrgentMessageCount > 0;
}
bool Connected() const;
private:
@ -576,6 +581,9 @@ class MessageChannel : HasResultCodes
// Set while we are dispatching a synchronous message.
bool mDispatchingSyncMessage;
// Count of the recursion depth of dispatching urgent messages.
size_t mDispatchingUrgentMessageCount;
// Queue of all incoming messages, except for replies to sync and urgent
// messages, which are delivered directly to mRecvd, and any pending urgent
// incall, which is stored in mPendingUrgentRequest.