mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Bug 1224825 - Race condition in MessagePort::close - patch 2, r=smaug
This commit is contained in:
parent
c29afb56a2
commit
5805634945
@ -295,7 +295,7 @@ MessagePort::MessagePort(nsPIDOMWindow* aWindow)
|
||||
|
||||
MessagePort::~MessagePort()
|
||||
{
|
||||
Close();
|
||||
CloseForced();
|
||||
MOZ_ASSERT(!mWorkerFeature);
|
||||
}
|
||||
|
||||
@ -604,6 +604,13 @@ MessagePort::CloseInternal(bool aSoftly)
|
||||
return;
|
||||
}
|
||||
|
||||
// Maybe we were already closing the port but softly. In this case we call
|
||||
// UpdateMustKeepAlive() to consider the empty pending message queue.
|
||||
if (mState == eStateDisentangledForClose && !aSoftly) {
|
||||
UpdateMustKeepAlive();
|
||||
return;
|
||||
}
|
||||
|
||||
if (mState > eStateEntangled) {
|
||||
return;
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ MessagePortService::CloseAllDebugCheck(const nsID& aID,
|
||||
#endif
|
||||
|
||||
void
|
||||
MessagePortService::CloseAll(const nsID& aUUID)
|
||||
MessagePortService::CloseAll(const nsID& aUUID, bool aForced)
|
||||
{
|
||||
MessagePortServiceData* data;
|
||||
if (!mPorts.Get(aUUID, &data)) {
|
||||
@ -299,7 +299,8 @@ MessagePortService::CloseAll(const nsID& aUUID)
|
||||
// because its entangling request didn't arrive yet), we cannot close this
|
||||
// channel.
|
||||
MessagePortServiceData* destinationData;
|
||||
if (mPorts.Get(destinationUUID, &destinationData) &&
|
||||
if (!aForced &&
|
||||
mPorts.Get(destinationUUID, &destinationData) &&
|
||||
!destinationData->mMessages.IsEmpty() &&
|
||||
destinationData->mWaitingForNewParent) {
|
||||
MOZ_ASSERT(!destinationData->mNextStepCloseAll);
|
||||
@ -309,7 +310,7 @@ MessagePortService::CloseAll(const nsID& aUUID)
|
||||
|
||||
mPorts.Remove(aUUID);
|
||||
|
||||
CloseAll(destinationUUID);
|
||||
CloseAll(destinationUUID, aForced);
|
||||
|
||||
// CloseAll calls itself recursively and it can happen that it deletes
|
||||
// itself. Before continuing we must check if we are still alive.
|
||||
@ -410,7 +411,7 @@ MessagePortService::ForceClose(const nsID& aUUID,
|
||||
return false;
|
||||
}
|
||||
|
||||
CloseAll(aUUID);
|
||||
CloseAll(aUUID, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
private:
|
||||
~MessagePortService() {}
|
||||
|
||||
void CloseAll(const nsID& aUUID);
|
||||
void CloseAll(const nsID& aUUID, bool aForced = false);
|
||||
void MaybeShutdown();
|
||||
|
||||
class MessagePortServiceData;
|
||||
|
Loading…
Reference in New Issue
Block a user