aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories
diff options
context:
space:
mode:
Diffstat (limited to 'Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories')
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.h4
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.m10
2 files changed, 8 insertions, 6 deletions
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.h b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.h
index ae3c8156..a3f34817 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.h
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.h
@@ -32,8 +32,8 @@
typedef struct {
MYSQL *mySQLConnection;
- BOOL *keepAlivePingActivePointer;
- BOOL *keepAliveLastPingSuccessPointer;
+ volatile BOOL *keepAlivePingThreadActivePointer;
+ volatile BOOL *keepAliveLastPingSuccessPointer;
} SPMySQLConnectionPingDetails;
@interface SPMySQLConnection (Ping_and_KeepAlive)
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.m
index c4469f5c..cfbb7183 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.m
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.m
@@ -140,7 +140,7 @@ end:
// Set up a query lock
[self _lockConnection];
- keepAliveLastPingSuccess = NO;
+ volatile BOOL keepAliveLastPingSuccess = NO;
keepAliveLastPingBlocked = NO;
keepAlivePingThreadActive = YES;
@@ -152,12 +152,14 @@ end:
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
@@ -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();