[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

kocienda kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:15:30 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit b67b72db04036dfd09bda9b8d9785bde98eca97b
Author: kocienda <kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Dec 16 17:27:27 2002 +0000

            Reviewed by Darin
    
    	Fix for these bugs:
    
    	Radar 3128622 (files that can't be mmap'd are opened twice)
    	Radar 3128624 (names of "not mappable" files kept in ever-growing set)
    
    	It turns out that simply reading in the bytes using the NSData
    	initWithContentsOfFile: method is faster than attempting to mmap
    	disk cache files to read them.
    
    	Since the mmap code is now removed, the issues raised by the bugs
    	simply go away.
    
            * Database.subproj/WebFileDatabase.m:
            (-[WebFileDatabase objectForKey:])
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3084 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/Misc.subproj/WebFileDatabase.m b/WebKit/Misc.subproj/WebFileDatabase.m
index 2b76b2d..b329517 100644
--- a/WebKit/Misc.subproj/WebFileDatabase.m
+++ b/WebKit/Misc.subproj/WebFileDatabase.m
@@ -113,132 +113,6 @@ static CFArrayRef CreateArrayListingFilesSortedByAccessTime(const char *path)
     return atimeArray;
 }
 
-// interface WebFileReader -------------------------------------------------------------
-
- at interface WebFileReader : NSObject
-{
-    NSData *data;
-    caddr_t mappedBytes;
-    size_t mappedLength;
-}
-
-- (id)initWithPath:(NSString *)path;
-- (NSData *)data;
-
- at end
-
-// implementation WebFileReader -------------------------------------------------------------
-
-static NSMutableSet *notMappableFileNameSet = nil;
-static NSLock *mutex;
-
-static void URLFileReaderInit(void)
-{
-    mutex = [[NSLock alloc] init];
-    notMappableFileNameSet = [[NSMutableSet alloc] init];    
-}
-
- at implementation WebFileReader
-
-- (id)initWithPath:(NSString *)path
-{
-    int fd;
-    struct stat statInfo;
-    const char *fileSystemPath;
-    BOOL fileNotMappable;
-    static pthread_once_t cacheFileReaderControl = PTHREAD_ONCE_INIT;
-
-    pthread_once(&cacheFileReaderControl, URLFileReaderInit);
-
-    [super init];
-
-    if (self == nil || path == nil) {
-        [self dealloc];
-        return nil;
-    }
-    
-    data = nil;
-    mappedBytes = NULL;
-    mappedLength = 0;
-
-    NS_DURING
-        fileSystemPath = [path fileSystemRepresentation];
-    NS_HANDLER
-        fileSystemPath = NULL;
-    NS_ENDHANDLER
-
-    [mutex lock];
-    fileNotMappable = [notMappableFileNameSet containsObject:path];
-    [mutex unlock];
-
-    if (fileNotMappable) {
-        data = [[NSData alloc] initWithContentsOfFile:path];
-    }
-    else if (fileSystemPath && (fd = open(fileSystemPath, O_RDONLY, 0)) >= 0) {
-        // File exists. Retrieve the file size.
-        if (fstat(fd, &statInfo) == 0) {
-            // Map the file into a read-only memory region.
-            mappedBytes = mmap(NULL, statInfo.st_size, PROT_READ, 0, fd, 0);
-            if (mappedBytes == MAP_FAILED) {
-                // map has failed but file exists
-                // add file to set of paths known not to be mappable
-                // then, read file from file system
-                [mutex lock];
-                [notMappableFileNameSet addObject:path];
-                [mutex unlock];
-                
-                mappedBytes = NULL;
-                data = [[NSData alloc] initWithContentsOfFile:path];
-            }
-            else {
-                // On success, create data object using mapped bytes.
-                mappedLength = statInfo.st_size;
-                data = [[NSData alloc] initWithBytesNoCopy:mappedBytes length:mappedLength freeWhenDone:NO];
-                // ok data creation failed but we know file exists
-                // be stubborn....try to read bytes again
-                if (!data) {
-                    munmap(mappedBytes, mappedLength);    
-                    data = [[NSData alloc] initWithContentsOfFile:path];
-                }
-            }
-        }
-        close(fd);
-    }
-    
-    if (data) {
-        if (mappedBytes) {
-            LOG(DiskCacheActivity, "mmaped disk cache file - %@", path);
-        }
-        else {
-            LOG(DiskCacheActivity, "fs read disk cache file - %@", path);
-        }
-        return self;
-    }
-    else {
-        LOG(DiskCacheActivity, "no disk cache file - %@", path);
-        [self dealloc];
-        return nil;
-    }
-}
-
-- (NSData *)data
-{
-    return data;
-}
-
-- (void)dealloc
-{
-    if (mappedBytes) {
-        munmap(mappedBytes, mappedLength); 
-    }
-    
-    [data release];
-    
-    [super dealloc];
-}
-
- at end
-
 // interface WebFileDatabaseOp -------------------------------------------------------------
 
 @interface WebFileDatabaseOp : NSObject
@@ -632,13 +506,11 @@ static void databaseInit()
 
     // go to disk
     NSString *filePath = [[NSString alloc] initWithFormat:@"%@/%@", path, [WebFileDatabase uniqueFilePathForKey:key]];
-    WebFileReader *fileReader = [[WebFileReader alloc] initWithPath:filePath];
-    
-    NSData *data;
+    NSData *data = [[NSData alloc] initWithContentsOfFile:filePath];
     NSUnarchiver * volatile unarchiver = nil;
 
     NS_DURING
-        if (fileReader && (data = [fileReader data])) {
+        if (data) {
             unarchiver = [[NSUnarchiver alloc] initForReadingWithData:data];
             if (unarchiver) {
                 id fileKey = [unarchiver decodeObject];
@@ -648,6 +520,7 @@ static void databaseInit()
                         // Decoded objects go away when the unarchiver does, so we need to
                         // retain this so we can return it to our caller.
                         result = [[object retain] autorelease];
+                        LOG(DiskCacheActivity, "read disk cache file - %@", key);
                     }
                 }
             }
@@ -658,7 +531,7 @@ static void databaseInit()
     NS_ENDHANDLER
 
     [unarchiver release];
-    [fileReader release];
+    [data release];
     [filePath release];
 
     return result;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list