More debugging cleanups

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@27782 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2009-02-04 15:14:39 +00:00
parent caf400979f
commit 76c5af245a
3 changed files with 37 additions and 30 deletions

View file

@ -3,6 +3,7 @@
* Source/NSURLProtocol.m: Add some diagnostics and ensure that * Source/NSURLProtocol.m: Add some diagnostics and ensure that
delegates are removed from streams. delegates are removed from streams.
* Source/NSURLConnection.m: Add diagnostics for redirect. * Source/NSURLConnection.m: Add diagnostics for redirect.
* Source/GSStream.m: Set delegate to nil after failure.
2009-02-04 David Chisnall <csdavec@swansea.ac.uk> 2009-02-04 David Chisnall <csdavec@swansea.ac.uk>

View file

@ -274,6 +274,14 @@ static RunLoopEventType typeForStream(NSStream *aStream)
} }
- (void) setDelegate: (id)delegate - (void) setDelegate: (id)delegate
{
if ([self streamStatus] == NSStreamStatusClosed
|| [self streamStatus] == NSStreamStatusError)
{
_delegateValid = NO;
_delegate = nil;
}
else
{ {
if (delegate) if (delegate)
{ {
@ -283,9 +291,6 @@ static RunLoopEventType typeForStream(NSStream *aStream)
{ {
_delegate = self; _delegate = self;
} }
if ([self streamStatus] != NSStreamStatusClosed
&& [self streamStatus] != NSStreamStatusError)
{
/* We don't want to send any events the the delegate after the /* We don't want to send any events the the delegate after the
* stream has been closed. * stream has been closed.
*/ */

View file

@ -129,10 +129,18 @@ static NSLock *pairLock = nil;
- (void) dealloc - (void) dealloc
{ {
[ip release]; [ip setDelegate: nil];
[op release]; [op setDelegate: nil];
[host release]; [ip removeFromRunLoop: [NSRunLoop currentRunLoop]
[expires release]; forMode: NSDefaultRunLoopMode];
[op removeFromRunLoop: [NSRunLoop currentRunLoop]
forMode: NSDefaultRunLoopMode];
[ip close];
[op close];
DESTROY(ip);
DESTROY(op);
DESTROY(host);
DESTROY(expires);
[super dealloc]; [super dealloc];
} }
@ -537,14 +545,6 @@ static NSURLProtocol *placeholder = nil;
[super dealloc]; [super dealloc];
} }
- (void) _schedule
{
[this->input scheduleInRunLoop: [NSRunLoop currentRunLoop]
forMode: NSDefaultRunLoopMode];
[this->output scheduleInRunLoop: [NSRunLoop currentRunLoop]
forMode: NSDefaultRunLoopMode];
}
- (void) setDebug: (BOOL)flag - (void) setDebug: (BOOL)flag
{ {
_debug = flag; _debug = flag;
@ -696,20 +696,15 @@ static NSURLProtocol *placeholder = nil;
} }
[this->input setDelegate: self]; [this->input setDelegate: self];
[this->output setDelegate: self]; [this->output setDelegate: self];
[self _schedule]; [this->input scheduleInRunLoop: [NSRunLoop currentRunLoop]
forMode: NSDefaultRunLoopMode];
[this->output scheduleInRunLoop: [NSRunLoop currentRunLoop]
forMode: NSDefaultRunLoopMode];
[this->input open]; [this->input open];
[this->output open]; [this->output open];
} }
} }
- (void) _unschedule
{
[this->input removeFromRunLoop: [NSRunLoop currentRunLoop]
forMode: NSDefaultRunLoopMode];
[this->output removeFromRunLoop: [NSRunLoop currentRunLoop]
forMode: NSDefaultRunLoopMode];
}
- (void) stopLoading - (void) stopLoading
{ {
if (_debug == YES) if (_debug == YES)
@ -722,7 +717,10 @@ static NSURLProtocol *placeholder = nil;
{ {
[this->input setDelegate: nil]; [this->input setDelegate: nil];
[this->output setDelegate: nil]; [this->output setDelegate: nil];
[self _unschedule]; [this->input removeFromRunLoop: [NSRunLoop currentRunLoop]
forMode: NSDefaultRunLoopMode];
[this->output removeFromRunLoop: [NSRunLoop currentRunLoop]
forMode: NSDefaultRunLoopMode];
[this->input close]; [this->input close];
[this->output close]; [this->output close];
DESTROY(this->input); DESTROY(this->input);
@ -1093,7 +1091,10 @@ static NSURLProtocol *placeholder = nil;
} }
} }
[self _unschedule]; [this->input removeFromRunLoop: [NSRunLoop currentRunLoop]
forMode: NSDefaultRunLoopMode];
[this->output removeFromRunLoop: [NSRunLoop currentRunLoop]
forMode: NSDefaultRunLoopMode];
if (_shouldClose == YES) if (_shouldClose == YES)
{ {
[this->input setDelegate: nil]; [this->input setDelegate: nil];