aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/MCPKit/MCPFoundationKit
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2009-11-10 21:29:19 +0000
committerrowanbeentje <rowan@beent.je>2009-11-10 21:29:19 +0000
commit938e8654b76383396ee187ab751bb8fa6d67f37a (patch)
tree3aaf8a7df7fb3582663adee8a0227091f5cd2bcf /Frameworks/MCPKit/MCPFoundationKit
parente122d2c8e45b19982b9b62b9b0ec39248d1d0bd4 (diff)
downloadsequelpro-938e8654b76383396ee187ab751bb8fa6d67f37a.tar.gz
sequelpro-938e8654b76383396ee187ab751bb8fa6d67f37a.tar.bz2
sequelpro-938e8654b76383396ee187ab751bb8fa6d67f37a.zip
- Add safeguards to ensure sequential runs when holding down run all/run selected keys in Custom Query, preventing NSLock deadlocks
- Revery MCPConnection to locking on the *current* thread when running non-streaming queries, fixing deadlocks in some situations on background threads where the main thread is locked up via a modal loop - eg CSV import windows
Diffstat (limited to 'Frameworks/MCPKit/MCPFoundationKit')
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m14
1 files changed, 9 insertions, 5 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
index 55c1ef3d..456b615d 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
@@ -1340,8 +1340,10 @@ void performThreadedKeepAlive(void *ptr)
}
}
- // Lock the connection
- [self lockConnection];
+ // Lock the connection - on this thread for normal result sets (avoiding blocking issues
+ // when the app is in modal mode), or ensuring a lock on the main thread for streaming queries.
+ if (streamResultType == MCP_NO_STREAMING) [queryLock lock];
+ else [self lockConnection];
// Run (or re-run) the query, timing the execution time of the query - note
// that this time will include network lag.
@@ -1360,7 +1362,7 @@ void performThreadedKeepAlive(void *ptr)
// For normal result sets, fetch the results and unlock the connection
if (streamResultType == MCP_NO_STREAMING) {
theResult = [[MCPResult alloc] initWithMySQLPtr:mConnection encoding:mEncoding timeZone:mTimeZone];
- [self unlockConnection];
+ [queryLock unlock];
// For streaming result sets, fetch the result pointer and leave the connection locked
} else if (streamResultType == MCP_FAST_STREAMING) {
@@ -1376,7 +1378,8 @@ void performThreadedKeepAlive(void *ptr)
break;
}
} else {
- [self unlockConnection];
+ if (streamResultType == MCP_NO_STREAMING) [queryLock unlock];
+ else [self unlockConnection];
}
queryErrorMessage = [[NSString alloc] initWithString:@""];
@@ -1387,7 +1390,8 @@ void performThreadedKeepAlive(void *ptr)
// On failure, set the error messages and IDs
} else {
- [self unlockConnection];
+ if (streamResultType == MCP_NO_STREAMING) [queryLock unlock];
+ else [self unlockConnection];
queryErrorMessage = [[NSString alloc] initWithString:[self stringWithCString:mysql_error(mConnection)]];
queryErrorId = mysql_errno(mConnection);