diff options
Diffstat (limited to 'Frameworks/SPMySQLFramework')
-rw-r--r-- | Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.h | 1 | ||||
-rw-r--r-- | Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.m | 10 |
2 files changed, 8 insertions, 3 deletions
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.h b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.h index a3f34817..1bd9f85b 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.h +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.h @@ -34,6 +34,7 @@ typedef struct { MYSQL *mySQLConnection; volatile BOOL *keepAlivePingThreadActivePointer; volatile BOOL *keepAliveLastPingSuccessPointer; + void *parentId; } 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 7940b483..374d0909 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Ping & KeepAlive.m @@ -33,6 +33,7 @@ #import "SPMySQL Private APIs.h" #import "Locking.h" #import <pthread.h> +#include <stdio.h> @implementation SPMySQLConnection (Ping_and_KeepAlive) @@ -85,7 +86,7 @@ } keepAliveThread = [NSThread currentThread]; - [keepAliveThread setName:@"SPMySQL connection keepalive monitor thread"]; + [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) { @@ -158,6 +159,7 @@ end_cleanup: pingDetails->mySQLConnection = mySQLConnection; pingDetails->keepAliveLastPingSuccessPointer = &keepAliveLastPingSuccess; pingDetails->keepAlivePingThreadActivePointer = &keepAlivePingThreadActive; + pingDetails->parentId = self; // Create a pthread for the ping pthread_t keepAlivePingThread_t; @@ -216,9 +218,11 @@ end_cleanup: */ void _backgroundPingTask(void *ptr) { - pthread_setname_np("SPMySQL _backgroundPingTask() worker thread"); - SPMySQLConnectionPingDetails *pingDetails = (SPMySQLConnectionPingDetails *)ptr; + + char threadNameBuf[80]; + snprintf(threadNameBuf, sizeof(threadNameBuf), "SPMySQL _backgroundPingTask() worker thread (id=%p)", pingDetails->parentId); + pthread_setname_np(threadNameBuf); // Set up a cleanup routine pthread_cleanup_push(_pingThreadCleanup, pingDetails); |