aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2012-10-14 16:09:45 +0000
committerrowanbeentje <rowan@beent.je>2012-10-14 16:09:45 +0000
commitdc45c654aab99cbccecda192396dc8baefd5690e (patch)
treea1b0a16eb468e191177c3617fc1f3c73c3e4750f /Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m
parent7d14dae0476ee3e3ab7c2fac391c506ac320d5ea (diff)
downloadsequelpro-dc45c654aab99cbccecda192396dc8baefd5690e.tar.gz
sequelpro-dc45c654aab99cbccecda192396dc8baefd5690e.tar.bz2
sequelpro-dc45c654aab99cbccecda192396dc8baefd5690e.zip
- In the SPMySQL.framework, separate framework-triggered connections and disconnections from external actions, and use that separation to perform safer disconnects
- When closing a database document, add a new notification, and use that to resolve retain cycles affecting connection processes - Improve connection controller disconnection when the document is closed, fixing crashes, by building on those two features (addresses Issue #1396) - Use some of the new functionality to improve SSH and MySQL connection cancellation, making both cancelable in the interface and making both respond much more quickly
Diffstat (limited to 'Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m')
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m13
1 files changed, 9 insertions, 4 deletions
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m
index bafa1e6e..22e35648 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m
@@ -222,6 +222,11 @@
lastQueryWasCancelled = NO;
lastQueryWasCancelledUsingReconnect = NO;
+ // If a disconnect was requested, cancel the action
+ if (userTriggeredDisconnect) {
+ return nil;
+ }
+
// Check the connection state - if no connection is available, log an
// error and return.
if (state == SPMySQLDisconnected || state == SPMySQLConnecting) {
@@ -368,6 +373,7 @@
// Unlock the connection if appropriate - if not a streaming result type.
if (![theResult isKindOfClass:[SPMySQLStreamingResult class]]) {
+ [self _tryLockConnection];
[self _unlockConnection];
// Also perform restore if appropriate
@@ -514,7 +520,6 @@
// so set up a new connection to run the KILL command.
MYSQL *killerConnection = [self _makeRawMySQLConnectionWithEncoding:@"utf8" isMasterConnection:NO];
-
// If the new connection was successfully set up, use it to run a KILL command.
if (killerConnection) {
NSStringEncoding aStringEncoding = [SPMySQLConnection stringEncodingForMySQLCharset:mysql_character_set_name(killerConnection)];
@@ -553,7 +558,7 @@
} else {
NSLog(@"SPMySQL Framework: query cancellation failed due to cancellation query error (status %d)", killQueryStatus);
}
- } else {
+ } else if (!userTriggeredDisconnect) {
NSLog(@"SPMySQL Framework: query cancellation failed because connection failed");
}
@@ -565,13 +570,13 @@
return;
}
- if (state == SPMySQLDisconnecting) return;
+ if (state == SPMySQLDisconnecting || state == SPMySQLDisconnected) return;
// Reset the connection with a reconnect. Unlock the connection beforehand,
// to allow the reconnect, but lock it again afterwards to restore the expected
// state (query execution process should unlock as appropriate).
[self _unlockConnection];
- [self reconnect];
+ [self _reconnectAllowingRetries:YES];
[self _lockConnection];
// Reset tracking bools to cover encompassed queries