From 79eff5bf42154da8d7730e0e0159160f68ec4e16 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Wed, 14 Mar 2012 01:16:18 +0000 Subject: =?UTF-8?q?Final=20feature=20work=20on=20the=20SPMySQL=20branch=20?= =?UTF-8?q?before=20merging:=20=20-=20Add=20a=20ping=20keepalive=20managin?= =?UTF-8?q?g=20object=20to=20prevent=20retain=20cycles=20from=20the=20NSTi?= =?UTF-8?q?mer=20=20-=20Add=20-[SPMySQLConnection=20copy]=20support=20=20-?= =?UTF-8?q?=20Refactor=20Hans-J=C3=B6rg=20Bibiko's=20database=20structure?= =?UTF-8?q?=20retrieval,=20moving=20it=20out=20of=20the=20MySQL=20framewor?= =?UTF-8?q?k=20and=20building=20it=20around=20a=20copy=20of=20the=20connec?= =?UTF-8?q?tion.=20=20This=20reduces=20the=20amount=20of=20connections-ove?= =?UTF-8?q?r-time=20used=20by=20Sequel=20Pro=20to=20two=20constant=20conne?= =?UTF-8?q?ctions=20(addressing=20Issue=20#1097)=20and=20improves=20robust?= =?UTF-8?q?ness.=20=20-=20Use=20the=20database=20structure=20retrieval=20c?= =?UTF-8?q?onnection=20for=20faster=20query=20cancellation=20without=20an?= =?UTF-8?q?=20extra=20connection=20required,=20if=20possible?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m') diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m index 4968266d..4f1e8a74 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m @@ -31,6 +31,7 @@ // More info at #import "SPMySQL Private APIs.h" +#import "SPMySQLKeepAliveTimer.h" #include #include #include @@ -71,6 +72,7 @@ const char *SPMySQLSSLPermissibleCiphers = "DHE-RSA-AES256-SHA:AES256-SHA:DHE-RS @synthesize mysqlConnectionThreadId; @synthesize retryQueriesOnConnectionFailure; @synthesize delegateQueryLogging; +@synthesize lastQueryWasCancelled; #pragma mark - #pragma mark Initialisation and teardown @@ -161,11 +163,7 @@ const char *SPMySQLSSLPermissibleCiphers = "DHE-RSA-AES256-SHA:AES256-SHA:DHE-RS retryQueriesOnConnectionFailure = YES; // Start the ping keepalive timer - if ([NSThread isMainThread]) { - [self _initKeepAlivePingTimer]; - } else { - [self performSelectorOnMainThread:@selector(_initKeepAlivePingTimer) withObject:nil waitUntilDone:YES]; - } + keepAliveTimer = [[SPMySQLKeepAliveTimer alloc] initWithInterval:10 target:self selector:@selector(_keepAlive)]; } return self; @@ -181,6 +179,10 @@ const char *SPMySQLSSLPermissibleCiphers = "DHE-RSA-AES256-SHA:AES256-SHA:DHE-RS // Unset the delegate [self setDelegate:nil]; + // Clear the keepalive timer + [keepAliveTimer invalidate]; + [keepAliveTimer release]; + // Disconnect if appropriate (which should also disconnect any proxy) [self disconnect]; @@ -196,14 +198,12 @@ const char *SPMySQLSSLPermissibleCiphers = "DHE-RSA-AES256-SHA:AES256-SHA:DHE-RS } [connectionLock release], connectionLock = nil; - [encoding dealloc]; + [encoding release]; if (previousEncoding) [previousEncoding release], previousEncoding = nil; if (database) [database release], database = nil; if (serverVersionString) [serverVersionString release], serverVersionString = nil; if (queryErrorMessage) [queryErrorMessage release], queryErrorMessage = nil; - [keepAliveTimer invalidate]; - [keepAliveTimer release]; [delegateDecisionLock release]; [NSObject cancelPreviousPerformRequestsWithTarget:self]; -- cgit v1.2.3