[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 06:13:47 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 959bbe0bc4a9894536a9dbe5cb74ffbc90491e34
Author: kocienda <kocienda at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Mon May 20 21:54:33 2002 +0000
2002-05-20 Kenneth Kocienda <kocienda at apple.com>
Reviewed by: John Sullivan
Fix for this bug:
Radar 2931078 (IFURLFileDatabase initialization is not threadsafe)
In addition, I have added several assertion checks to the code. Note
that each of these assertion checks is of the "failure should be impossible"
variety.
* Database.subproj/IFURLFileDatabase.m:
(-[IFURLFileReader initWithPath:]):
(-[IFURLFileDatabaseOp initWithCode:key:object:]):
(-[IFURLFileDatabaseOp perform:]):
(databaseInit):
(-[IFURLFileDatabase initWithPath:]):
(-[IFURLFileDatabase setObject:forKey:]):
(-[IFURLFileDatabase removeObjectForKey:]):
(-[IFURLFileDatabase objectForKey:]):
(-[IFURLFileDatabase performSetObject:forKey:]):
(-[IFURLFileDatabase performRemoveObjectForKey:]):
(-[IFURLFileDatabase lazySync:]):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1178 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit/Misc.subproj/WebFileDatabase.m b/WebKit/Misc.subproj/WebFileDatabase.m
index 8e4656d..a2d6259 100644
--- a/WebKit/Misc.subproj/WebFileDatabase.m
+++ b/WebKit/Misc.subproj/WebFileDatabase.m
@@ -15,6 +15,9 @@
#define SIZE_FILE_NAME @".size"
+// The next line is a workaround for Radar 2905545. Once that's fixed, it can use PTHREAD_ONCE_INIT.
+static void databaseInit(void);
+static pthread_once_t databaseInitControl = {_PTHREAD_ONCE_SIG_init, {}};
static NSNumber *IFURLFileDirectoryPosixPermissions;
static NSNumber *IFURLFilePosixPermissions;
@@ -71,6 +74,11 @@ static void URLFileReaderInit(void)
pthread_once(&cacheFileReaderControl, URLFileReaderInit);
[super init];
+
+ if (self == nil || path == nil) {
+ [self dealloc];
+ return nil;
+ }
data = nil;
mappedBytes = NULL;
@@ -185,6 +193,9 @@ static void URLFileReaderInit(void)
-(id)initWithCode:(IFURLFileDatabaseOpCode)theOpcode key:(id)theKey object:(id)theObject
{
+ WEBFOUNDATION_ASSERT_NOT_NIL(theKey);
+ WEBFOUNDATION_ASSERT_NOT_NIL(theObject);
+
if ((self = [super init])) {
opcode = theOpcode;
@@ -215,6 +226,8 @@ static void URLFileReaderInit(void)
-(void)perform:(IFURLFileDatabase *)target
{
+ WEBFOUNDATION_ASSERT_NOT_NIL(target);
+
switch (opcode) {
case IFURLFileDatabaseSetObjectOp:
[target performSetObject:object forKey:key];
@@ -222,6 +235,9 @@ static void URLFileReaderInit(void)
case IFURLFileDatabaseRemoveObjectOp:
[target performRemoveObjectForKey:key];
break;
+ default:
+ WEBFOUNDATION_ASSERT_NOT_NIL(nil);
+ break;
}
}
@@ -381,7 +397,7 @@ static void URLFileReaderInit(void)
// creation functions ---------------------------------------------------------------------------
#pragma mark creation functions
-+(void)initialize
+static void databaseInit()
{
// set file perms to owner read/write/execute only
IFURLFileDirectoryPosixPermissions = [[NSNumber numberWithInt:(IF_UREAD | IF_UWRITE | IF_UEXEC)] retain];
@@ -392,20 +408,23 @@ static void URLFileReaderInit(void)
-(id)initWithPath:(NSString *)thePath
{
- if ((self = [super initWithPath:thePath])) {
+ pthread_once(&databaseInitControl, databaseInit);
+
+ [super initWithPath:thePath];
- ops = [[NSMutableArray alloc] init];
- setCache = [[NSMutableDictionary alloc] init];
- removeCache = [[NSMutableSet alloc] init];
- timer = nil;
- mutex = [[NSRecursiveLock alloc] init];
- sizeFilePath = NULL;
-
- return self;
+ if (self == nil || thePath == nil) {
+ [self dealloc];
+ return nil;
}
+
+ ops = [[NSMutableArray alloc] init];
+ setCache = [[NSMutableDictionary alloc] init];
+ removeCache = [[NSMutableSet alloc] init];
+ timer = nil;
+ mutex = [[NSRecursiveLock alloc] init];
+ sizeFilePath = NULL;
- [self release];
- return nil;
+ return self;
}
-(void)dealloc
@@ -434,6 +453,9 @@ static void URLFileReaderInit(void)
{
IFURLFileDatabaseOp *op;
+ WEBFOUNDATION_ASSERT_NOT_NIL(object);
+ WEBFOUNDATION_ASSERT_NOT_NIL(key);
+
touch = CFAbsoluteTimeGetCurrent();
[mutex lock];
@@ -450,6 +472,8 @@ static void URLFileReaderInit(void)
{
IFURLFileDatabaseOp *op;
+ WEBFOUNDATION_ASSERT_NOT_NIL(key);
+
touch = CFAbsoluteTimeGetCurrent();
[mutex lock];
@@ -493,6 +517,8 @@ static void URLFileReaderInit(void)
data = nil;
unarchiver = nil;
+ WEBFOUNDATION_ASSERT_NOT_NIL(key);
+
touch = CFAbsoluteTimeGetCurrent();
// check caches
@@ -553,6 +579,9 @@ static void URLFileReaderInit(void)
NSArchiver *archiver;
NSFileManager *defaultManager;
+ WEBFOUNDATION_ASSERT_NOT_NIL(object);
+ WEBFOUNDATION_ASSERT_NOT_NIL(key);
+
WEBFOUNDATIONDEBUGLEVEL(WebFoundationLogDiskCacheActivity, "performSetObject - %s - %s",
DEBUG_OBJECT(key), DEBUG_OBJECT([IFURLFileDatabase uniqueFilePathForKey:key]));
@@ -600,6 +629,8 @@ static void URLFileReaderInit(void)
NSDictionary *attributes;
NSNumber *size;
+ WEBFOUNDATION_ASSERT_NOT_NIL(key);
+
WEBFOUNDATIONDEBUGLEVEL(WebFoundationLogDiskCacheActivity, "performRemoveObjectForKey - %s", DEBUG_OBJECT(key));
filePath = [[NSString alloc] initWithFormat:@"%@/%@", path, [IFURLFileDatabase uniqueFilePathForKey:key]];
@@ -677,6 +708,8 @@ static void URLFileReaderInit(void)
{
IFURLFileDatabaseOp *op;
+ WEBFOUNDATION_ASSERT_NOT_NIL(theTimer);
+
while (touch + SYNC_IDLE_THRESHOLD < CFAbsoluteTimeGetCurrent() && [ops count] > 0) {
[mutex lock];
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list