mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-25 17:51:01 +00:00
Wrap lock protected sections with exception handlers.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@7935 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
6d5cd2c799
commit
f994d1ee90
2 changed files with 70 additions and 21 deletions
|
@ -1,5 +1,7 @@
|
||||||
2000-10-30 Richard Frith-Macdonald <rfm@gnu.org>
|
2000-10-30 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSURLHandle.m: Wrap all locking with exception handlers to
|
||||||
|
ensure that locks are released.
|
||||||
* Headers/gnustep/base/NSInvocation.h: Removed non-standard macros
|
* Headers/gnustep/base/NSInvocation.h: Removed non-standard macros
|
||||||
* Headers/gnustep/base/behavior.h: Removed unused macro
|
* Headers/gnustep/base/behavior.h: Removed unused macro
|
||||||
CALL_METHOD_IN_CLASS()
|
CALL_METHOD_IN_CLASS()
|
||||||
|
|
|
@ -97,31 +97,49 @@ static Class NSURLHandleClass = 0;
|
||||||
* be used in preference to any class added earlier.
|
* be used in preference to any class added earlier.
|
||||||
*/
|
*/
|
||||||
[registryLock lock];
|
[registryLock lock];
|
||||||
[registry removeObjectIdenticalTo: urlHandleSubclass];
|
NS_DURING
|
||||||
[registry addObject: urlHandleSubclass];
|
{
|
||||||
|
[registry removeObjectIdenticalTo: urlHandleSubclass];
|
||||||
|
[registry addObject: urlHandleSubclass];
|
||||||
|
}
|
||||||
|
NS_HANDLER
|
||||||
|
{
|
||||||
|
[registryLock unlock];
|
||||||
|
[localException raise];
|
||||||
|
}
|
||||||
|
NS_ENDHANDLER
|
||||||
[registryLock unlock];
|
[registryLock unlock];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (Class) URLHandleClassForURL: (NSURL*)url
|
+ (Class) URLHandleClassForURL: (NSURL*)url
|
||||||
{
|
{
|
||||||
unsigned count;
|
unsigned count;
|
||||||
|
Class c = 0;
|
||||||
|
|
||||||
[registryLock lock];
|
[registryLock lock];
|
||||||
count = [registry count];
|
NS_DURING
|
||||||
|
|
||||||
/*
|
|
||||||
* Find a class to handle the URL, try most recently registered first.
|
|
||||||
*/
|
|
||||||
while (count-- > 0)
|
|
||||||
{
|
{
|
||||||
id found = [registry objectAtIndex: count];
|
count = [registry count];
|
||||||
|
|
||||||
if ([found canInitWithURL: url] == YES)
|
/*
|
||||||
|
* Find a class to handle the URL, try most recently registered first.
|
||||||
|
*/
|
||||||
|
while (count-- > 0)
|
||||||
{
|
{
|
||||||
[registryLock unlock];
|
id found = [registry objectAtIndex: count];
|
||||||
return (Class)found;
|
|
||||||
|
if ([found canInitWithURL: url] == YES)
|
||||||
|
{
|
||||||
|
c = (Class)found;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
NS_HANDLER
|
||||||
|
{
|
||||||
|
[registryLock unlock];
|
||||||
|
[localException raise];
|
||||||
|
}
|
||||||
|
NS_ENDHANDLER
|
||||||
[registryLock unlock];
|
[registryLock unlock];
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -404,8 +422,17 @@ static NSLock *fileLock = nil;
|
||||||
|
|
||||||
path = [path stringByStandardizingPath];
|
path = [path stringByStandardizingPath];
|
||||||
[fileLock lock];
|
[fileLock lock];
|
||||||
obj = [fileCache objectForKey: path];
|
NS_DURING
|
||||||
AUTORELEASE(RETAIN(obj));
|
{
|
||||||
|
obj = [fileCache objectForKey: path];
|
||||||
|
AUTORELEASE(RETAIN(obj));
|
||||||
|
}
|
||||||
|
NS_HANDLER
|
||||||
|
{
|
||||||
|
[fileLock unlock];
|
||||||
|
[localException raise];
|
||||||
|
}
|
||||||
|
NS_ENDHANDLER
|
||||||
[fileLock unlock];
|
[fileLock unlock];
|
||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
|
@ -451,15 +478,26 @@ static NSLock *fileLock = nil;
|
||||||
id obj;
|
id obj;
|
||||||
|
|
||||||
[fileLock lock];
|
[fileLock lock];
|
||||||
obj = [fileCache objectForKey: path];
|
NS_DURING
|
||||||
|
{
|
||||||
|
obj = [fileCache objectForKey: path];
|
||||||
|
if (obj != nil)
|
||||||
|
{
|
||||||
|
DESTROY(self);
|
||||||
|
RETAIN(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
NS_HANDLER
|
||||||
|
{
|
||||||
|
[fileLock unlock];
|
||||||
|
[localException raise];
|
||||||
|
}
|
||||||
|
NS_ENDHANDLER
|
||||||
|
[fileLock unlock];
|
||||||
if (obj != nil)
|
if (obj != nil)
|
||||||
{
|
{
|
||||||
RELEASE(self);
|
return obj;
|
||||||
self = RETAIN(obj);
|
|
||||||
[fileLock unlock];
|
|
||||||
return self;
|
|
||||||
}
|
}
|
||||||
[fileLock unlock];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((self = [super initWithURL: url cached: cached]) != nil)
|
if ((self = [super initWithURL: url cached: cached]) != nil)
|
||||||
|
@ -468,7 +506,16 @@ static NSLock *fileLock = nil;
|
||||||
if (cached == YES)
|
if (cached == YES)
|
||||||
{
|
{
|
||||||
[fileLock lock];
|
[fileLock lock];
|
||||||
[fileCache setObject: self forKey: _path];
|
NS_DURING
|
||||||
|
{
|
||||||
|
[fileCache setObject: self forKey: _path];
|
||||||
|
}
|
||||||
|
NS_HANDLER
|
||||||
|
{
|
||||||
|
[fileLock unlock];
|
||||||
|
[localException raise];
|
||||||
|
}
|
||||||
|
NS_ENDHANDLER
|
||||||
[fileLock unlock];
|
[fileLock unlock];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue