diff options
Diffstat (limited to 'Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories')
3 files changed, 15 insertions, 0 deletions
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.m index 3ce0c0cd..3201b55f 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.m @@ -187,6 +187,9 @@ void _backgroundPingTask(void *ptr) // Set up a cleanup routine pthread_cleanup_push(_pingThreadCleanup, pingDetails); + // Initialise MySQL variables and handling on this thread + mysql_thread_init(); + // Set up a signal handler for SIGUSR1, to handle forced timeouts. signal(SIGUSR1, _forceThreadExit); @@ -209,6 +212,9 @@ void _pingThreadCleanup(void *pingDetails) { SPMySQLConnectionPingDetails *pingDetailsStruct = pingDetails; *(pingDetailsStruct->keepAlivePingActivePointer) = NO; + + // Clean up MySQL variables and handlers + mysql_thread_end(); } @end diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m index 5df71e96..46615cae 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Querying & Preparation.m @@ -76,6 +76,9 @@ } if (![self _checkConnectionIfNecessary]) return nil; + // Ensure per-thread variables are set up + [self _validateThreadSetup]; + // Perform a lossy conversion to bytes, using NSData to do the hard work. Preserves // nul characters correctly. NSData *cData = [theString dataUsingEncoding:stringEncoding allowLossyConversion:YES]; @@ -229,6 +232,9 @@ return nil; } + // Ensure per-thread variables are set up + [self _validateThreadSetup]; + // Check the connection if necessary, returning nil if the query couldn't be validated if (![self _checkConnectionIfNecessary]) return nil; diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Server Info.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Server Info.m index f695d977..1022ccd1 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Server Info.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Server Info.m @@ -137,6 +137,9 @@ // Lock the connection before using it [self _lockConnection]; + // Ensure per-thread variables are set up + [self _validateThreadSetup]; + // Get the process list MYSQL_RES *mysqlResult = mysql_list_processes(mySQLConnection); |