Skip to content

Commit

Permalink
Fix a warning on 10.6 about memory leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
dmoagx committed May 18, 2018
1 parent f20ab36 commit 38b9659
Showing 1 changed file with 33 additions and 31 deletions.
Expand Up @@ -87,43 +87,45 @@ - (void)_keepAlive
*/
- (void)_threadedKeepAlive
{
@synchronized(self) {
if(keepAliveThread) {
NSLog(@"warning: overwriting existing keepAliveThread: %@, results may be unpredictable!",keepAliveThread);
@autoreleasepool {
@synchronized(self) {
if(keepAliveThread) {
NSLog(@"warning: overwriting existing keepAliveThread: %@, results may be unpredictable!",keepAliveThread);
}
keepAliveThread = [NSThread currentThread];
}
keepAliveThread = [NSThread currentThread];
}

[keepAliveThread setName:[NSString stringWithFormat:@"SPMySQL connection keepalive monitor thread (id=%p)", self]];

// If the maximum number of ping failures has been reached, determine whether to reconnect.
if (keepAliveLastPingBlocked || keepAlivePingFailures >= 3) {
[keepAliveThread setName:[NSString stringWithFormat:@"SPMySQL connection keepalive monitor thread (id=%p)", self]];

// If the connection has been used within the last fifteen minutes,
// attempt a single reconnection in the background
if (_elapsedSecondsSinceAbsoluteTime(lastConnectionUsedTime) < 60 * 15) {
[self _reconnectAfterBackgroundConnectionLoss];
}
// Otherwise set the state to connection lost for automatic reconnect on
// next use.
else {
state = SPMySQLConnectionLostInBackground;
}
// If the maximum number of ping failures has been reached, determine whether to reconnect.
if (keepAliveLastPingBlocked || keepAlivePingFailures >= 3) {

// Return as no further ping action required this cycle.
goto end_cleanup;
}
// If the connection has been used within the last fifteen minutes,
// attempt a single reconnection in the background
if (_elapsedSecondsSinceAbsoluteTime(lastConnectionUsedTime) < 60 * 15) {
[self _reconnectAfterBackgroundConnectionLoss];
}
// Otherwise set the state to connection lost for automatic reconnect on
// next use.
else {
state = SPMySQLConnectionLostInBackground;
}

// Otherwise, perform a background ping.
BOOL pingResult = [self _pingConnectionUsingLoopDelay:10000];
if (pingResult) {
keepAlivePingFailures = 0;
} else {
keepAlivePingFailures++;
}
// Return as no further ping action required this cycle.
goto end_cleanup;
}

// Otherwise, perform a background ping.
BOOL pingResult = [self _pingConnectionUsingLoopDelay:10000];
if (pingResult) {
keepAlivePingFailures = 0;
} else {
keepAlivePingFailures++;
}
end_cleanup:
@synchronized(self) {
keepAliveThread = nil;
@synchronized(self) {
keepAliveThread = nil;
}
}
}

Expand Down

0 comments on commit 38b9659

Please sign in to comment.