Permalink
Browse files

Fixes issue #49 - potential memory leak of autorelease pool. Also swi…

…tching from releasing autorelease pools to draining them for improved support for garbage collection.
  • Loading branch information...
robbiehanson committed Jun 3, 2011
1 parent fe4d019 commit 2ae7ed625dcf9c554af00c06a03deebabd3af058
Showing with 11 additions and 10 deletions.
  1. +6 −5 HTTPConnection.m
  2. +3 −3 HTTPServer.m
  3. +2 −2 WebSocket.m
View
@@ -561,14 +561,15 @@ - (void)addBasicAuthChallenge:(HTTPMessage *)response
- (void)start
{
dispatch_async(connectionQueue, ^{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
if (started) return;
started = YES;
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
[self startConnection];
- [pool release];
+ [pool drain];
});
}
@@ -583,7 +584,7 @@ - (void)stop
[self die];
- [pool release];
+ [pool drain];
});
}
@@ -2300,7 +2301,7 @@ - (void)responseHasAvailableData:(NSObject<HTTPResponse> *)sender
}
}
- [pool release];
+ [pool drain];
});
}
@@ -2330,7 +2331,7 @@ - (void)responseDidAbort:(NSObject<HTTPResponse> *)sender
[asyncSocket disconnectAfterWriting];
- [pool release];
+ [pool drain];
});
}
View
@@ -437,7 +437,7 @@ - (BOOL)start:(NSError **)errPtr
[err retain];
}
- [pool release];
+ [pool drain];
});
if (errPtr)
@@ -480,7 +480,7 @@ - (BOOL)stop
[webSockets removeAllObjects];
[webSocketsLock unlock];
- [pool release];
+ [pool drain];
});
return YES;
@@ -758,7 +758,7 @@ + (void)bonjourThread
HTTPLogVerbose(@"%@: BonjourThread: Aborted", THIS_FILE);
- [pool release];
+ [pool drain];
}
+ (void)performBonjourBlock:(dispatch_block_t)block
View
@@ -206,7 +206,7 @@ - (void)start
[self didOpen];
}
- [pool release];
+ [pool drain];
});
}
@@ -224,7 +224,7 @@ - (void)stop
[asyncSocket disconnect];
- [pool release];
+ [pool drain];
});
}

0 comments on commit 2ae7ed6

Please sign in to comment.