From 6c3ab14a0cb89e64256c1d3e7db57adb3d45057c Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 9 Mar 2017 01:14:55 +0100 Subject: Add a bit of debug info in Connection pinging --- .../Source/SPMySQLConnection Categories/Ping & KeepAlive.h | 1 + .../Source/SPMySQLConnection Categories/Ping & KeepAlive.m | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'Frameworks/SPMySQLFramework') 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 +#include @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); -- cgit v1.2.3