aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/MCPKit/MCPFoundationKit
diff options
context:
space:
mode:
Diffstat (limited to 'Frameworks/MCPKit/MCPFoundationKit')
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m6
1 files changed, 6 insertions, 0 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
index 1a4786ec..7f5c4365 100644
--- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
+++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m
@@ -689,6 +689,12 @@ void pingConnectionTask(void *ptr)
*/
- (void)stopKeepAliveTimer
{
+ // Stop keepalives on the main thread to avoid memory issues
+ if (![NSThread isMainThread]) {
+ [self performSelectorOnMainThread:@selector(stopKeepAliveTimer) withObject:nil waitUntilDone:NO];
+ return;
+ }
+
if (keepAliveThread != NULL) pthread_cancel(keepAliveThread), keepAliveThread = NULL;
if (!keepAliveTimer) return;
[keepAliveTimer invalidate];