зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1550037 - patch 2 - Ensure the font-list memory blocks passed to content processes are shared as readonly copies. r=jwatt
Differential Revision: https://phabricator.services.mozilla.com/D68779 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
1bf1c749a5
Коммит
68661385f7
|
@ -225,11 +225,12 @@ class FontList {
|
|||
*/
|
||||
void ShareShmBlockToProcess(uint32_t aIndex, base::ProcessId aPid,
|
||||
base::SharedMemoryHandle* aOut) {
|
||||
if (aIndex >= mBlocks.Length()) {
|
||||
MOZ_RELEASE_ASSERT(mReadOnlyShmems.Length() == mBlocks.Length());
|
||||
if (aIndex >= mReadOnlyShmems.Length()) {
|
||||
// Block index out of range
|
||||
*aOut = base::SharedMemory::NULLHandle();
|
||||
}
|
||||
if (!mBlocks[aIndex]->mShmem->ShareToProcess(aPid, aOut)) {
|
||||
if (!mReadOnlyShmems[aIndex]->ShareToProcess(aPid, aOut)) {
|
||||
MOZ_CRASH("failed to share block");
|
||||
}
|
||||
}
|
||||
|
@ -325,6 +326,12 @@ class FontList {
|
|||
* added a block (or blocks) to the list, and we need to update!
|
||||
*/
|
||||
nsTArray<mozilla::UniquePtr<ShmBlock>> mBlocks;
|
||||
|
||||
/**
|
||||
* Auxiliary array, used only in the parent process; holds read-only copies
|
||||
* of the shmem blocks; these are what will be shared to child processes.
|
||||
*/
|
||||
nsTArray<mozilla::UniquePtr<base::SharedMemory>> mReadOnlyShmems;
|
||||
};
|
||||
|
||||
} // namespace fontlist
|
||||
|
|
|
@ -520,7 +520,7 @@ FontList::~FontList() { DetachShmBlocks(); }
|
|||
bool FontList::AppendShmBlock() {
|
||||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
base::SharedMemory* newShm = new base::SharedMemory();
|
||||
if (!newShm->Create(SHM_BLOCK_SIZE)) {
|
||||
if (!newShm->CreateFreezeable(SHM_BLOCK_SIZE)) {
|
||||
MOZ_CRASH("failed to create shared memory");
|
||||
return false;
|
||||
}
|
||||
|
@ -541,6 +541,13 @@ bool FontList::AppendShmBlock() {
|
|||
mBlocks.AppendElement(block);
|
||||
GetHeader().mBlockCount.store(mBlocks.Length());
|
||||
|
||||
auto* readOnly = new base::SharedMemory();
|
||||
if (!newShm->ReadOnlyCopy(readOnly)) {
|
||||
MOZ_CRASH("failed to create read-only copy");
|
||||
return false;
|
||||
}
|
||||
mReadOnlyShmems.AppendElement(readOnly);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -548,7 +555,8 @@ void FontList::DetachShmBlocks() {
|
|||
for (auto& i : mBlocks) {
|
||||
i->mShmem = nullptr;
|
||||
}
|
||||
mBlocks.SetLength(0);
|
||||
mBlocks.Clear();
|
||||
mReadOnlyShmems.Clear();
|
||||
}
|
||||
|
||||
FontList::ShmBlock* FontList::GetBlockFromParent(uint32_t aIndex) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче