From d8896ae0a22b0014d0b43706280c8a390f14b058 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Sun, 14 Oct 2012 19:22:45 +0000 Subject: - Clean up some connection cancellation/close-during-connect edges as a result of r3894, attempting to improve some exceptions during aborted connections - Name threads created in SPMySQL.framework --- .../Source/SPMySQLConnection Categories/Delegate & Proxy.m | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Delegate & Proxy.m') diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Delegate & Proxy.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Delegate & Proxy.m index e0b745e0..9f6d8dff 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Delegate & Proxy.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Delegate & Proxy.m @@ -95,6 +95,7 @@ */ - (void)_proxyStateChange:(NSObject *)aProxy { + NSThread *reconnectionThread; // Perform no actions if this isn't the current connection proxy, or if notifications // are currently set to be ignored @@ -112,11 +113,15 @@ // Trigger a reconnect depending on connection usage recently. If the connection has // actively been used in the last couple of minutes, trigger a full reconnection attempt. if (_elapsedSecondsSinceAbsoluteTime(lastConnectionUsedTime) < 60 * 2) { - [NSThread detachNewThreadSelector:@selector(reconnect) toTarget:self withObject:nil]; - + reconnectionThread = [[[NSThread alloc] initWithTarget:self selector:@selector(_reconnectAllowingRetries:) object:[NSNumber numberWithBool:YES]] autorelease]; + [reconnectionThread setName:@"SPMySQL reconnection thread (full)"]; + [reconnectionThread start]; + // If used within the last fifteen minutes, trigger a background/single reconnection attempt } else if (_elapsedSecondsSinceAbsoluteTime(lastConnectionUsedTime) < 60 * 15) { - [NSThread detachNewThreadSelector:@selector(_reconnectAfterBackgroundConnectionLoss) toTarget:self withObject:nil]; + reconnectionThread = [[[NSThread alloc] initWithTarget:self selector:@selector(_reconnectAfterBackgroundConnectionLoss:) object:nil] autorelease]; + [reconnectionThread setName:@"SPMySQL reconnection thread (limited)"]; + [reconnectionThread start]; // Otherwise set the state to connection lost for automatic reconnect on next use } else { -- cgit v1.2.3