Changeset 244678 in webkit
- Timestamp:
- Apr 25, 2019 11:06:10 PM (5 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r244675 r244678 1 2019-04-25 Alex Christensen <achristensen@webkit.org> 2 3 Make NetworkCache blobs safe for mmap instead of not using blobs 4 https://bugs.webkit.org/show_bug.cgi?id=197264 5 <rdar://problem/49564348> 6 7 Reviewed by Antti Koivisto. 8 9 This does what r244597 did for WKContentRuleLists but for the NetworkCache's blobs. 10 Those are the two cases where we were calling mmap and seeing crashes in apps with 11 default file protection of NSFileProtectionComplete. 12 13 * NetworkProcess/cache/NetworkCacheBlobStorage.cpp: 14 (WebKit::NetworkCache::BlobStorage::add): 15 * NetworkProcess/cache/NetworkCacheFileSystem.cpp: 16 (WebKit::NetworkCache::isSafeToUseMemoryMapForPath): Deleted. 17 * NetworkProcess/cache/NetworkCacheFileSystem.h: 18 * NetworkProcess/cache/NetworkCacheFileSystemCocoa.mm: 19 (WebKit::NetworkCache::isSafeToUseMemoryMapForPath): 20 * NetworkProcess/cache/NetworkCacheStorage.cpp: 21 (WebKit::NetworkCache::Storage::Storage): 22 (WebKit::NetworkCache::Storage::synchronize): 23 (WebKit::NetworkCache::Storage::mayContainBlob const): 24 (WebKit::NetworkCache::Storage::shouldStoreBodyAsBlob): 25 (WebKit::NetworkCache::estimateRecordsSize): Deleted. 26 * NetworkProcess/cache/NetworkCacheStorage.h: 27 1 28 2019-04-25 Simon Fraser <simon.fraser@apple.com> 2 29 -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheBlobStorage.cpp
r240437 r244678 94 94 return { data, hash }; 95 95 96 auto blobPath = FileSystem::fileSystemRepresentation(blobPathForHash(hash)); 96 String blobPathString = blobPathForHash(hash); 97 makeSafeToUseMemoryMapForPath(blobPathString); 98 99 auto blobPath = FileSystem::fileSystemRepresentation(blobPathString); 97 100 auto linkPath = FileSystem::fileSystemRepresentation(path); 98 101 unlink(linkPath.data()); -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.cpp
r244597 r244678 147 147 148 148 #if !PLATFORM(IOS_FAMILY) 149 bool isSafeToUseMemoryMapForPath(const String&)150 {151 return true;152 }153 149 void makeSafeToUseMemoryMapForPath(const String&) 154 150 { -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.h
r244597 r244678 43 43 void updateFileModificationTimeIfNeeded(const String& path); 44 44 45 bool isSafeToUseMemoryMapForPath(const String&);46 45 void makeSafeToUseMemoryMapForPath(const String&); 47 46 -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystemCocoa.mm
r244597 r244678 34 34 35 35 #if PLATFORM(IOS_FAMILY) 36 bool isSafeToUseMemoryMapForPath(const String& path)36 static bool isSafeToUseMemoryMapForPath(const String& path) 37 37 { 38 // FIXME: For the network cache we should either use makeSafeToUseMemoryMapForPath instead of this39 // or we should listen to UIApplicationProtectedDataWillBecomeUnavailable and unmap files.40 38 NSError *error = nil; 41 39 NSDictionary<NSFileAttributeKey, id> *attributes = [[NSFileManager defaultManager] attributesOfItemAtPath:path error:&error]; -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp
r244645 r244678 229 229 , m_mode(mode) 230 230 , m_salt(salt) 231 , m_canUseBlobsForForBodyData(isSafeToUseMemoryMapForPath(baseDirectoryPath))232 231 , m_readOperationTimeoutTimer(*this, &Storage::cancelAllReadOperations) 233 232 , m_writeOperationDispatchTimer(*this, &Storage::dispatchPendingWriteOperations) … … 296 295 297 296 // Most of the disk space usage is in blobs if we are using them. Approximate records file sizes to avoid expensive stat() calls. 298 bool shouldComputeExactRecordsSize = !m_canUseBlobsForForBodyData;299 297 size_t recordsSize = 0; 300 298 unsigned recordCount = 0; … … 319 317 ++recordCount; 320 318 321 if (shouldComputeExactRecordsSize) {322 long long fileSize = 0;323 FileSystem::getFileSize(filePath, fileSize);324 recordsSize += fileSize;325 }326 327 319 recordFilter->add(hash); 328 320 }); 329 321 330 if (!shouldComputeExactRecordsSize) 331 recordsSize = estimateRecordsSize(recordCount, blobCount); 322 recordsSize = estimateRecordsSize(recordCount, blobCount); 332 323 333 324 m_blobStorage.synchronize(); … … 378 369 { 379 370 ASSERT(RunLoop::isMain()); 380 if (!m_canUseBlobsForForBodyData)381 return false;382 371 return !m_blobFilter || m_blobFilter->mayContain(key.hash()); 383 372 } … … 795 784 bool Storage::shouldStoreBodyAsBlob(const Data& bodyData) 796 785 { 797 if (!m_canUseBlobsForForBodyData)798 return false;799 786 return bodyData.size() > maximumInlineBodySize; 800 787 } -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.h
r243143 r244678 170 170 const Mode m_mode; 171 171 const Salt m_salt; 172 const bool m_canUseBlobsForForBodyData;173 172 174 173 size_t m_capacity { std::numeric_limits<size_t>::max() };
Note: See TracChangeset
for help on using the changeset viewer.