mirror of
https://github.com/gnustep/libs-sqlclient.git
synced 2025-02-15 16:11:42 +00:00
lock safety fixes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/sqlclient/trunk@35832 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
1fdb15cfb0
commit
1f11ea97a9
2 changed files with 162 additions and 110 deletions
|
@ -1,3 +1,8 @@
|
|||
2012-11-29 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Wrap more code in exception handlers where there is any potential
|
||||
for an exception in a lock protected region.
|
||||
|
||||
2012-11-10 Niels Grewe <niels.grewe@halbordnung.de>
|
||||
|
||||
* GNUmakefile: Link against $(FND_LIBS) and $(OBJC_LIBS) instead
|
||||
|
|
65
SQLClient.m
65
SQLClient.m
|
@ -1161,6 +1161,8 @@ static unsigned int maxConnections = 8;
|
|||
{
|
||||
[lock lock];
|
||||
if (connected == NO)
|
||||
{
|
||||
NS_DURING
|
||||
{
|
||||
if (_connectFails > 1)
|
||||
{
|
||||
|
@ -1179,8 +1181,7 @@ static unsigned int maxConnections = 8;
|
|||
[NSThread sleepForTimeInterval: delay - elapsed];
|
||||
}
|
||||
}
|
||||
NS_DURING
|
||||
{
|
||||
|
||||
[self backendConnect];
|
||||
/* On establishng a new connection, we must restore any
|
||||
* listen instructions in the backend.
|
||||
|
@ -1284,6 +1285,8 @@ static unsigned int maxConnections = 8;
|
|||
NSMutableString *s = [[NSMutableString new] autorelease];
|
||||
|
||||
[lock lock];
|
||||
NS_DURING
|
||||
{
|
||||
[s appendFormat: @"Database - %@\n", [self clientName]];
|
||||
[s appendFormat: @" Name - %@\n", [self name]];
|
||||
[s appendFormat: @" DBase - %@\n", [self database]];
|
||||
|
@ -1291,7 +1294,8 @@ static unsigned int maxConnections = 8;
|
|||
[s appendFormat: @" Password - %@\n",
|
||||
[self password] == nil ? @"unknown" : @"known"];
|
||||
[s appendFormat: @" Connected - %@\n", connected ? @"yes" : @"no"];
|
||||
[s appendFormat: @" Transaction - %@\n", _inTransaction ? @"yes" : @"no"];
|
||||
[s appendFormat: @" Transaction - %@\n",
|
||||
_inTransaction ? @"yes" : @"no"];
|
||||
if (_cache == nil)
|
||||
{
|
||||
[s appendString: @"\n"];
|
||||
|
@ -1300,6 +1304,13 @@ static unsigned int maxConnections = 8;
|
|||
{
|
||||
[s appendFormat: @" Cache - %@\n", _cache];
|
||||
}
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
[lock unlock];
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
[lock unlock];
|
||||
return s;
|
||||
}
|
||||
|
@ -1838,12 +1849,16 @@ static unsigned int maxConnections = 8;
|
|||
|
||||
- (NSInteger) simpleExecute: (NSArray*)info
|
||||
{
|
||||
NSString *statement;
|
||||
NSInteger result;
|
||||
|
||||
[lock lock];
|
||||
NS_DURING
|
||||
{
|
||||
NSTimeInterval start = 0.0;
|
||||
NSString *statement;
|
||||
BOOL isCommit = NO;
|
||||
BOOL isRollback = NO;
|
||||
|
||||
[lock lock];
|
||||
statement = [info objectAtIndex: 0];
|
||||
|
||||
if ([statement isEqualToString: commitString])
|
||||
|
@ -1855,10 +1870,6 @@ static unsigned int maxConnections = 8;
|
|||
isRollback = YES;
|
||||
}
|
||||
|
||||
NS_DURING
|
||||
{
|
||||
NSTimeInterval start = 0.0;
|
||||
|
||||
if (_duration >= 0)
|
||||
{
|
||||
start = GSTickerTimeNow();
|
||||
|
@ -2877,6 +2888,8 @@ static unsigned int maxConnections = 8;
|
|||
- (void) setCache: (GSCache*)aCache
|
||||
{
|
||||
[lock lock];
|
||||
NS_DURING
|
||||
{
|
||||
if (_cacheThread != nil)
|
||||
{
|
||||
[_cache setDelegate: nil];
|
||||
|
@ -2888,6 +2901,13 @@ static unsigned int maxConnections = 8;
|
|||
{
|
||||
[_cache setDelegate: self];
|
||||
}
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
[lock unlock];
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
[lock unlock];
|
||||
}
|
||||
|
||||
|
@ -2906,6 +2926,8 @@ static unsigned int maxConnections = 8;
|
|||
aThread = mainThread;
|
||||
}
|
||||
[lock lock];
|
||||
NS_DURING
|
||||
{
|
||||
if (_cacheThread != nil)
|
||||
{
|
||||
[_cache setDelegate: nil];
|
||||
|
@ -2917,6 +2939,13 @@ static unsigned int maxConnections = 8;
|
|||
{
|
||||
[_cache setDelegate: self];
|
||||
}
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
[lock unlock];
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
[lock unlock];
|
||||
}
|
||||
@end
|
||||
|
@ -3342,6 +3371,8 @@ validName(NSString *name)
|
|||
|
||||
name = validName(name);
|
||||
[lock lock];
|
||||
NS_DURING
|
||||
{
|
||||
if (nil == _observers)
|
||||
{
|
||||
_observers = NSCreateMapTable(NSNonRetainedObjectMapKeyCallBacks,
|
||||
|
@ -3370,6 +3401,13 @@ validName(NSString *name)
|
|||
selector: aSelector
|
||||
name: name
|
||||
object: self];
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
[lock unlock];
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
[lock unlock];
|
||||
}
|
||||
|
||||
|
@ -3394,6 +3432,8 @@ validName(NSString *name)
|
|||
name = validName(name);
|
||||
}
|
||||
[lock lock];
|
||||
NS_DURING
|
||||
{
|
||||
if (_observers != nil)
|
||||
{
|
||||
NSNotificationCenter *nc;
|
||||
|
@ -3429,6 +3469,13 @@ validName(NSString *name)
|
|||
name = [e nextObject];
|
||||
}
|
||||
}
|
||||
}
|
||||
NS_HANDLER
|
||||
{
|
||||
[lock unlock];
|
||||
[localException raise];
|
||||
}
|
||||
NS_ENDHANDLER
|
||||
[lock unlock];
|
||||
}
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue