aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2010-03-08 10:11:29 +0000
committerrowanbeentje <rowan@beent.je>2010-03-08 10:11:29 +0000
commitc10728213ede7dbdd37493aca9657ab4010edbdc (patch)
tree0a474d090b87c5d833e77b75654871de040293ad /Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h
parentd638ce370f202cb9d8338eeb3f981d9f70f548ff (diff)
downloadsequelpro-c10728213ede7dbdd37493aca9657ab4010edbdc.tar.gz
sequelpro-c10728213ede7dbdd37493aca9657ab4010edbdc.tar.bz2
sequelpro-c10728213ede7dbdd37493aca9657ab4010edbdc.zip
Rework MCPConnection for greater thread safety:
- The delegate is now triggered for connectionLost: on the main thread, as this action will probably trigger a GUI update; this addresses http://log.sequelpro.com/view/10 . - Connection proxy disconnects are now triggered on the main thread - Connection checks are now made via a pthread'd ping in a loop, removing the reliance on SIGALRM which may hop thread execution back to the main thread when called on another thread. The new approach is cleaner but does rely on a loop with a sleep. This will hopefully improve the disconnect/retry/reconnect crashes.
Diffstat (limited to 'Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h')
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h
index 84b18a26..f04fb26e 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h
@@ -85,7 +85,7 @@ static inline NSData* NSStringDataUsingLossyEncoding(NSString* self, NSInteger e
NSInteger connectionTimeout;
CGFloat keepAliveInterval;
- id <MCPConnectionProxy> connectionProxy;
+ NSObject <MCPConnectionProxy> *connectionProxy;
NSString *connectionLogin;
NSString *connectionPassword;
NSString *connectionHost;
@@ -101,6 +101,7 @@ static inline NSData* NSStringDataUsingLossyEncoding(NSString* self, NSInteger e
NSString *lastQueryErrorMessage;
NSUInteger lastQueryErrorId;
my_ulonglong lastQueryAffectedRows;
+ MCPConnectionCheck lastDelegateDecisionForLostConnection;
BOOL isMaxAllowedPacketEditable;
@@ -110,6 +111,7 @@ static inline NSData* NSStringDataUsingLossyEncoding(NSString* self, NSInteger e
NSTimer *keepAliveTimer;
pthread_t keepAliveThread;
+ pthread_t pingThread;
uint64_t connectionStartTime;
BOOL retryAllowed;
@@ -117,6 +119,7 @@ static inline NSData* NSStringDataUsingLossyEncoding(NSString* self, NSInteger e
BOOL queryCancelUsedReconnect;
BOOL delegateQueryLogging;
BOOL delegateResponseToWillQueryString;
+ BOOL delegateSupportsConnectionLostDecisions;
BOOL isQueryingDbStructure;
// Pointers
@@ -150,6 +153,7 @@ static inline NSData* NSStringDataUsingLossyEncoding(NSString* self, NSInteger e
// Delegate
- (id)delegate;
- (void)setDelegate:(id)connectionDelegate;
+- (MCPConnectionCheck)delegateDecisionForLostConnection;
// Connection details
- (BOOL)setPort:(NSInteger)thePort;
@@ -166,6 +170,7 @@ static inline NSData* NSStringDataUsingLossyEncoding(NSString* self, NSInteger e
- (BOOL)isConnected;
- (BOOL)checkConnection;
- (BOOL)pingConnection;
+void pingConnectionTask(void *ptr);
- (void)startKeepAliveTimer;
- (void)stopKeepAliveTimer;
- (void)keepAlive:(NSTimer *)theTimer;