aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/MCPKit
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2010-11-03 23:55:22 +0000
committerrowanbeentje <rowan@beent.je>2010-11-03 23:55:22 +0000
commite185e73e733edc9357e3642a4bb1fc9b9f2c0748 (patch)
tree64122e78e2e3d29368fa1342d3cc4f1bae2efb1e /Frameworks/MCPKit
parent14cab5efffa90887562c18517bff68b2ec97d4bd (diff)
downloadsequelpro-e185e73e733edc9357e3642a4bb1fc9b9f2c0748.tar.gz
sequelpro-e185e73e733edc9357e3642a4bb1fc9b9f2c0748.tar.bz2
sequelpro-e185e73e733edc9357e3642a4bb1fc9b9f2c0748.zip
- Improve query disconnection/reconnection while pings or queries are still active or cleaning up
Diffstat (limited to 'Frameworks/MCPKit')
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m31
1 files changed, 28 insertions, 3 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
index 48509969..653f9b2f 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
@@ -502,9 +502,20 @@ static BOOL sTruncateLongFieldInLogs = YES;
if (mConnected) {
[self cancelCurrentQuery];
mConnected = NO;
-
- // Small pause for cleanup.
- usleep(100000);
+
+ // Allow any pings or query cleanups to complete - within a time limit.
+ uint64_t startTime_t, currentTime_t;
+ Nanoseconds elapsedNanoseconds;
+ startTime_t = mach_absolute_time();
+ do {
+ usleep(100000);
+
+ currentTime_t = mach_absolute_time() - startTime_t ;
+ elapsedNanoseconds = AbsoluteToNanoseconds(*(AbsoluteTime *)&(currentTime_t));
+ if (((double)UnsignedWideToUInt64(elapsedNanoseconds)) * 1e-9 > 10) break;
+ } while (![self tryLockConnection]);
+ [self unlockConnection];
+
if (mConnection->net.vio && mConnection->net.buff) mysql_close(mConnection);
mConnection = NULL;
}
@@ -544,6 +555,20 @@ static BOOL sTruncateLongFieldInLogs = YES;
// Close the connection if it exists.
if (mConnected) {
+
+ // Allow any pings or query cleanups to complete - within a time limit.
+ uint64_t startTime_t, currentTime_t;
+ Nanoseconds elapsedNanoseconds;
+ startTime_t = mach_absolute_time();
+ do {
+ usleep(100000);
+
+ currentTime_t = mach_absolute_time() - startTime_t ;
+ elapsedNanoseconds = AbsoluteToNanoseconds(*(AbsoluteTime *)&(currentTime_t));
+ if (((double)UnsignedWideToUInt64(elapsedNanoseconds)) * 1e-9 > 10) break;
+ } while (![self tryLockConnection]);
+ [self unlockConnection];
+
if (mConnection->net.vio && mConnection->net.buff) mysql_close(mConnection);
mConnection = NULL;
}