Changeset 182124 in webkit
- Timestamp:
- Mar 29, 2015, 4:43:32 PM (10 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/Source/WebKit2/ChangeLog ¶
r182101 r182124 1 2015-03-29 Antti Koivisto <antti@apple.com> 2 3 Use st_mtime instead of st_atime to track file access time 4 https://bugs.webkit.org/show_bug.cgi?id=143200 5 6 Reviewed by Darin Adler. 7 8 On OS X atime updates automatically on read so calling Storage::traverse() would always ends up updating access times 9 for all cache entries to the current time. This would make entry worth computation produce unexpected results. 10 We update mtime manually on successful cache retrieve only so switching to it fixes the problem. 11 12 * NetworkProcess/cache/NetworkCacheFileSystemPosix.h: 13 (WebKit::NetworkCache::fileTimes): 14 (WebKit::NetworkCache::updateFileModificationTimeIfNeeded): 15 (WebKit::NetworkCache::updateFileAccessTimeIfNeeded): Deleted. 16 * NetworkProcess/cache/NetworkCacheStorage.cpp: 17 (WebKit::NetworkCache::Storage::updateFileModificationTime): 18 (WebKit::NetworkCache::Storage::dispatchReadOperation): 19 (WebKit::NetworkCache::deletionProbability): 20 (WebKit::NetworkCache::Storage::updateFileAccessTime): Deleted. 21 * NetworkProcess/cache/NetworkCacheStorage.h: 22 1 23 2015-03-27 Gwang Yoon Hwang <yoon@igalia.com> 2 24 -
TabularUnified trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheFileSystemPosix.h ¶
r181700 r182124 72 72 struct FileTimes { 73 73 std::chrono::system_clock::time_point creation; 74 std::chrono::system_clock::time_point access;74 std::chrono::system_clock::time_point modification; 75 75 }; 76 76 … … 80 80 if (stat(WebCore::fileSystemRepresentation(path).data(), &fileInfo)) 81 81 return { }; 82 return { std::chrono::system_clock::from_time_t(fileInfo.st_birthtime), std::chrono::system_clock::from_time_t(fileInfo.st_ atime) };82 return { std::chrono::system_clock::from_time_t(fileInfo.st_birthtime), std::chrono::system_clock::from_time_t(fileInfo.st_mtime) }; 83 83 } 84 84 85 inline void updateFile AccessTimeIfNeeded(const String& path)85 inline void updateFileModificationTimeIfNeeded(const String& path) 86 86 { 87 87 auto times = fileTimes(path); 88 if (times.creation != times. access) {89 // Don't update more than once per hour ;90 if (std::chrono::system_clock::now() - times. access< std::chrono::hours(1))88 if (times.creation != times.modification) { 89 // Don't update more than once per hour. 90 if (std::chrono::system_clock::now() - times.modification < std::chrono::hours(1)) 91 91 return; 92 92 } 93 // This really updates both access time andmodification time.93 // This really updates both the access time and the modification time. 94 94 utimes(WebCore::fileSystemRepresentation(path).data(), 0); 95 95 } -
TabularUnified trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp ¶
r182019 r182124 293 293 } 294 294 295 void Storage::updateFile AccessTime(IOChannel& channel)295 void Storage::updateFileModificationTime(IOChannel& channel) 296 296 { 297 297 StringCapture filePathCapture(channel.path()); 298 298 serialBackgroundIOQueue().dispatch([filePathCapture] { 299 updateFile AccessTimeIfNeeded(filePathCapture.string());299 updateFileModificationTimeIfNeeded(filePathCapture.string()); 300 300 }); 301 301 } … … 317 317 bool success = read.completionHandler(WTF::move(record)); 318 318 if (success) 319 updateFile AccessTime(*channel);319 updateFileModificationTime(*channel); 320 320 else 321 321 remove(read.key); … … 590 590 using namespace std::chrono; 591 591 auto age = system_clock::now() - times.creation; 592 auto accessAge = times.access - times.creation; 592 // File modification time is updated manually on cache read. We don't use access time since OS may update it automatically. 593 auto accessAge = times.modification - times.creation; 593 594 594 595 // For sanity. -
TabularUnified trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h ¶
r182019 r182124 98 98 void dispatchPendingWriteOperations(); 99 99 100 void updateFile AccessTime(IOChannel&);100 void updateFileModificationTime(IOChannel&); 101 101 102 102 WorkQueue& ioQueue() { return m_ioQueue.get(); }
Note:
See TracChangeset
for help on using the changeset viewer.