|
33 | 33 | #import "SPMySQL Private APIs.h"
|
34 | 34 | #import "Locking.h"
|
35 | 35 | #import <pthread.h>
|
| 36 | +#include <stdio.h> |
36 | 37 |
|
37 | 38 | @implementation SPMySQLConnection (Ping_and_KeepAlive)
|
38 | 39 |
|
@@ -85,7 +86,7 @@ - (void)_threadedKeepAlive
|
85 | 86 | }
|
86 | 87 |
|
87 | 88 | keepAliveThread = [NSThread currentThread];
|
88 |
| - [keepAliveThread setName:@"SPMySQL connection keepalive monitor thread"]; |
| 89 | + [keepAliveThread setName:[NSString stringWithFormat:@"SPMySQL connection keepalive monitor thread (id=%p)", self]]; |
89 | 90 |
|
90 | 91 | // If the maximum number of ping failures has been reached, determine whether to reconnect.
|
91 | 92 | if (keepAliveLastPingBlocked || keepAlivePingFailures >= 3) {
|
@@ -158,6 +159,7 @@ - (BOOL)_pingConnectionUsingLoopDelay:(NSUInteger)loopDelay
|
158 | 159 | pingDetails->mySQLConnection = mySQLConnection;
|
159 | 160 | pingDetails->keepAliveLastPingSuccessPointer = &keepAliveLastPingSuccess;
|
160 | 161 | pingDetails->keepAlivePingThreadActivePointer = &keepAlivePingThreadActive;
|
| 162 | + pingDetails->parentId = self; |
161 | 163 |
|
162 | 164 | // Create a pthread for the ping
|
163 | 165 | pthread_t keepAlivePingThread_t;
|
@@ -216,9 +218,11 @@ - (BOOL)_pingConnectionUsingLoopDelay:(NSUInteger)loopDelay
|
216 | 218 | */
|
217 | 219 | void _backgroundPingTask(void *ptr)
|
218 | 220 | {
|
219 |
| - pthread_setname_np("SPMySQL _backgroundPingTask() worker thread"); |
220 |
| - |
221 | 221 | SPMySQLConnectionPingDetails *pingDetails = (SPMySQLConnectionPingDetails *)ptr;
|
| 222 | + |
| 223 | + char threadNameBuf[80]; |
| 224 | + snprintf(threadNameBuf, sizeof(threadNameBuf), "SPMySQL _backgroundPingTask() worker thread (id=%p)", pingDetails->parentId); |
| 225 | + pthread_setname_np(threadNameBuf); |
222 | 226 |
|
223 | 227 | // Set up a cleanup routine
|
224 | 228 | pthread_cleanup_push(_pingThreadCleanup, pingDetails);
|
|
0 commit comments