Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* Remove some ivars that are only used as local vars
* Also I take back what I said about 4d97cbd and say it will happen now *duckundweg*
  • Loading branch information
dmoagx committed Oct 25, 2015
1 parent 2ed7473 commit 2b2a177
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
Expand Up @@ -32,8 +32,8 @@

typedef struct {
MYSQL *mySQLConnection;
BOOL *keepAlivePingActivePointer;
BOOL *keepAliveLastPingSuccessPointer;
volatile BOOL *keepAlivePingThreadActivePointer;
volatile BOOL *keepAliveLastPingSuccessPointer;
} SPMySQLConnectionPingDetails;

@interface SPMySQLConnection (Ping_and_KeepAlive)
Expand Down
Expand Up @@ -140,7 +140,7 @@ - (BOOL)_pingConnectionUsingLoopDelay:(NSUInteger)loopDelay
// Set up a query lock
[self _lockConnection];

keepAliveLastPingSuccess = NO;
volatile BOOL keepAliveLastPingSuccess = NO;
keepAliveLastPingBlocked = NO;
keepAlivePingThreadActive = YES;

Expand All @@ -152,12 +152,14 @@ - (BOOL)_pingConnectionUsingLoopDelay:(NSUInteger)loopDelay
SPMySQLConnectionPingDetails *pingDetails = malloc(sizeof(SPMySQLConnectionPingDetails));
pingDetails->mySQLConnection = mySQLConnection;
pingDetails->keepAliveLastPingSuccessPointer = &keepAliveLastPingSuccess;
pingDetails->keepAlivePingActivePointer = &keepAlivePingThreadActive;
pingDetails->keepAlivePingThreadActivePointer = &keepAlivePingThreadActive;

// Create a pthread for the ping
pthread_t keepAlivePingThread_t;

pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
pthread_create(&keepAlivePingThread_t, &attr, (void *)&_backgroundPingTask, pingDetails);

// Record the ping start time
Expand Down Expand Up @@ -245,7 +247,7 @@ void _forceThreadExit(int signalNumber)
void _pingThreadCleanup(void *pingDetails)
{
SPMySQLConnectionPingDetails *pingDetailsStruct = pingDetails;
*(pingDetailsStruct->keepAlivePingActivePointer) = NO;
*(pingDetailsStruct->keepAlivePingThreadActivePointer) = NO;

// Clean up MySQL variables and handlers
mysql_thread_end();
Expand Down
4 changes: 1 addition & 3 deletions Frameworks/SPMySQLFramework/Source/SPMySQLConnection.h
Expand Up @@ -86,9 +86,7 @@
uint64_t lastKeepAliveTime;
NSUInteger keepAlivePingFailures;
volatile NSThread *keepAliveThread;
pthread_t keepAlivePingThread_t;
BOOL keepAlivePingThreadActive;
BOOL keepAliveLastPingSuccess;
volatile BOOL keepAlivePingThreadActive;
BOOL keepAliveLastPingBlocked;

// Encoding details - and also a record of any previous encoding to allow
Expand Down
2 changes: 0 additions & 2 deletions Frameworks/SPMySQLFramework/Source/SPMySQLConnection.m
Expand Up @@ -145,9 +145,7 @@ - (id)init
keepAlivePingFailures = 0;
lastKeepAliveTime = 0;
keepAliveThread = nil;
keepAlivePingThread_t = NULL;
keepAlivePingThreadActive = NO;
keepAliveLastPingSuccess = NO;
keepAliveLastPingBlocked = NO;

// Set up default encoding variables
Expand Down

0 comments on commit 2b2a177

Please sign in to comment.