Skip to content

Commit

Permalink
Fix for #2353 ("Attempted to connect a connection that is not disconn…
Browse files Browse the repository at this point in the history
…ected")

Backport of 3aadea1
  • Loading branch information
dmoagx committed Feb 12, 2016
1 parent e168cbf commit 4341c2a
Show file tree
Hide file tree
Showing 5 changed files with 207 additions and 190 deletions.
Expand Up @@ -58,6 +58,9 @@ - (NSString *)escapeAndQuoteString:(NSString *)theString
* Take a string and escapes any special character for safe use within a query; correctly * Take a string and escapes any special character for safe use within a query; correctly
* escapes any characters within the string using the current connection encoding. * escapes any characters within the string using the current connection encoding.
* Allows control over whether to also wrap the string in single quotes. * Allows control over whether to also wrap the string in single quotes.
*
* WARNING: This method may return nil if the current thread is cancelled!
* You MUST check the isCancelled flag before using the result!
*/ */
- (NSString *)escapeString:(NSString *)theString includingQuotes:(BOOL)includeQuotes - (NSString *)escapeString:(NSString *)theString includingQuotes:(BOOL)includeQuotes
{ {
Expand Down Expand Up @@ -221,6 +224,9 @@ - (id)streamingQueryString:(NSString *)theQueryString useLowMemoryBlockingStream
* the connection encoding. * the connection encoding.
* The result type desired can be specified, supporting either standard or streaming * The result type desired can be specified, supporting either standard or streaming
* result sets. * result sets.
*
* WARNING: This method may return nil if the current thread is cancelled!
* You MUST check the isCancelled flag before using the result!
*/ */
- (id)queryString:(NSString *)theQueryString usingEncoding:(NSStringEncoding)theEncoding withResultType:(SPMySQLResultType)theReturnType - (id)queryString:(NSString *)theQueryString usingEncoding:(NSStringEncoding)theEncoding withResultType:(SPMySQLResultType)theReturnType
{ {
Expand Down
Expand Up @@ -124,6 +124,9 @@ - (BOOL)serverVersionIsGreaterThanOrEqualTo:(NSUInteger)aMajorVersion minorVersi
* the resulting process list defaults to the short form; run a manual SHOW FULL PROCESSLIST * the resulting process list defaults to the short form; run a manual SHOW FULL PROCESSLIST
* to retrieve tasks in non-truncated form. * to retrieve tasks in non-truncated form.
* Returns nil on error. * Returns nil on error.
*
* WARNING: This method may return nil if the current thread is cancelled!
* You MUST check the isCancelled flag before using the result!
*/ */
- (SPMySQLResult *)listProcesses - (SPMySQLResult *)listProcesses
{ {
Expand Down
13 changes: 12 additions & 1 deletion Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m
Expand Up @@ -263,6 +263,9 @@ - (BOOL)connect
* Error checks extensively - if this method fails, it will ask how to proceed and loop depending * Error checks extensively - if this method fails, it will ask how to proceed and loop depending
* on the status, not returning control until either a connection has been established or * on the status, not returning control until either a connection has been established or
* the connection and document have been closed. * the connection and document have been closed.
*
* WARNING: This method may exit early returning NO if the current thread is cancelled!
* You MUST check the isCancelled flag before using the result!
*/ */
- (BOOL)reconnect - (BOOL)reconnect
{ {
Expand Down Expand Up @@ -311,10 +314,12 @@ - (BOOL)isConnectedViaSSL
* Checks whether the connection to the server is still active. This verifies * Checks whether the connection to the server is still active. This verifies
* the connection using a ping, and if the connection is found to be down attempts * the connection using a ping, and if the connection is found to be down attempts
* to quickly restore it, including the previous state. * to quickly restore it, including the previous state.
*
* WARNING: This method may return NO if the current thread is cancelled!
* You MUST check the isCancelled flag before using the result!
*/ */
- (BOOL)checkConnection - (BOOL)checkConnection
{ {

// If the connection is not seen as active, don't proceed // If the connection is not seen as active, don't proceed
if (state != SPMySQLConnected) return NO; if (state != SPMySQLConnected) return NO;


Expand Down Expand Up @@ -607,6 +612,9 @@ - (MYSQL *)_makeRawMySQLConnectionWithEncoding:(NSString *)encodingName isMaster
* the connection and document have been closed. * the connection and document have been closed.
* Runs its own autorelease pool as sometimes called in a thread following proxy changes * Runs its own autorelease pool as sometimes called in a thread following proxy changes
* (where the return code doesn't matter). * (where the return code doesn't matter).
*
* WARNING: This method may exit early returning NO if the current thread is cancelled!
* You MUST check the isCancelled flag before using the result!
*/ */
- (BOOL)_reconnectAllowingRetries:(BOOL)canRetry - (BOOL)_reconnectAllowingRetries:(BOOL)canRetry
{ {
Expand Down Expand Up @@ -996,6 +1004,9 @@ - (void)_restoreConnectionVariables
* each of which requires a round trip to the server - but handles most * each of which requires a round trip to the server - but handles most
* network issues. * network issues.
* Returns whether the connection is considered still valid. * Returns whether the connection is considered still valid.
*
* WARNING: This method may return NO if the current thread is cancelled!
* You MUST check the isCancelled flag before using the result!
*/ */
- (BOOL)_checkConnectionIfNecessary - (BOOL)_checkConnectionIfNecessary
{ {
Expand Down
1 change: 0 additions & 1 deletion Source/SPDatabaseStructure.h
Expand Up @@ -51,7 +51,6 @@
// Setup and teardown // Setup and teardown
- (id)initWithDelegate:(SPDatabaseDocument *)theDelegate; - (id)initWithDelegate:(SPDatabaseDocument *)theDelegate;
- (void)setConnectionToClone:(SPMySQLConnection *)aConnection; - (void)setConnectionToClone:(SPMySQLConnection *)aConnection;
- (void)destroy:(NSNotification *)notification;


// Information // Information
- (SPMySQLConnection *)connection; - (SPMySQLConnection *)connection;
Expand Down

0 comments on commit 4341c2a

Please sign in to comment.