Permalink
Browse files

Add a bit of debug info in Connection pinging

  • Loading branch information...
dmoagx committed Mar 9, 2017
1 parent dd2e34f commit 6c3ab14a0cb89e64256c1d3e7db57adb3d45057c
@@ -34,6 +34,7 @@ typedef struct {
MYSQL *mySQLConnection;
volatile BOOL *keepAlivePingThreadActivePointer;
volatile BOOL *keepAliveLastPingSuccessPointer;
void *parentId;
} SPMySQLConnectionPingDetails;
@interface SPMySQLConnection (Ping_and_KeepAlive)
@@ -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 @@ - (void)_threadedKeepAlive
}
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 @@ - (BOOL)_pingConnectionUsingLoopDelay:(NSUInteger)loopDelay
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 @@ - (BOOL)_pingConnectionUsingLoopDelay:(NSUInteger)loopDelay
*/
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);

0 comments on commit 6c3ab14

Please sign in to comment.