• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSHTTPURLHandle bugs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSHTTPURLHandle bugs


  • Subject: Re: NSHTTPURLHandle bugs
  • From: Finlay Dobbie <email@hidden>
  • Date: Sun, 27 Jan 2002 21:33:25 +0000

For anybody at Apple, I've filed 2849072, and here's the contents for anybody else who might be interested:

* TITLE/SUMMARY
Under certain circumstances, NSHTTPURLHandle (the private NSURLHandle subclass for handling HTTP URLs) is causing my app to exit due to signal 13 (SIGPIPE).

* STEPS TO REPRODUCE
1) Make sure no local web server is listening on port 80.
2) Compile this Foundation tool:
----
#import <Foundation/Foundation.h>

@interface Client:NSObject <NSURLHandleClient>
@end

@implementation Client
- (void)URLHandle:(NSURLHandle *)sender resourceDataDidBecomeAvailable:(NSData *)newBytes {
NSLog(@"-[Client URLHandle:resourceDataDidBecomeAvailable:] fired");
}
- (void)URLHandleResourceDidBeginLoading:(NSURLHandle *)sender {
NSLog(@"-[Client URLHandleResourceDidBeginLoading:] fired");
}
- (void)URLHandleResourceDidFinishLoading:(NSURLHandle *)sender {
NSLog(@"-[Client URLHandleResourceDidBeginLoading:] fired");
}
- (void)URLHandleResourceDidCancelLoading:(NSURLHandle *)sender {
NSLog(@"-[Client URLHandleResourceDidCancelLoading:] fired");
}
- (void)URLHandle:(NSURLHandle *)sender resourceDidFailLoadingWithReason:(NSString *)reason {
NSLog(@"-[Client URLHandle:resourceDidFailLoadingWithReason:] fired, reason: %@", reason);
}
@end

int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSURLHandle *myHandle = [[NSURL URLWithString:@"http://localhost/asdf";] URLHandleUsingCache:NO];
Client *myClient = [[Client alloc] init];

[myHandle addClient:myClient];
[myHandle loadInBackground];

[[NSRunLoop currentRunLoop] run];

[pool release];
return 0;
}
----

* RESULTS
NSHTTPURLHandleBug has exited due to signal 13 (SIGPIPE).
I expected -[Client URLHandle:resourceDidFailLoadingWithReason:] to fire instead. Backtrace:
#0 0x70002938 in write ()
#1 0x701dd8e0 in fdWrite ()
#2 0x701e4cdc in socketWrite ()
#3 0x701c0ed8 in CFWriteStreamWrite ()
#4 0x75181e1c in CFHTTPMessageCopyBody ()
#5 0x75181c58 in CFHTTPMessageCopyBody ()
#6 0x75182e78 in CFHTTPMessageIsHeaderComplete ()
#7 0x701c9bb8 in _CFStreamGetCallBackPtr ()
#8 0x70829d08 in -[NSHTTPURLHandle beginLoadInBackground] ()
#9 0x708afb38 in -[NSURLHandle loadInBackground] ()
#10 0x00002b80 in main (argc=1, argv=0xbffffc20) at main.m:30/Users/finlayd/NSHTTPURLHandleBug/
#11 0x00002854 in _start ()
#12 0x00002684 in start ()

* NOTES
A partial workaround is to do something like this:
sigset_t sigset;
sigemptyset(&sigset);
sigaddset(&sigset, SIGPIPE);
sigprocmask(SIG_BLOCK, &sigset, NULL);
But that makes the loadInbackground hang for a substantial amount of time, making my GUI app unresponsive. Attempting to work around THAT (working around a workaround, hrmph) like this:
[NSThread detachNewThreadSelector:@selector(hangWorkaround) toTarget:self withObject:nil];
- (void)hangWorkaround {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[iniURLHandle loadInBackground];
[pool release];
}
causes other problems, because the URLHandle creates the DO inter-thread communication channel to the wrong thread.

-- Finlay


References: 
 >NSHTTPURLHandle bugs (From: Finlay Dobbie <email@hidden>)

  • Prev by Date: Re: [LONG] Making the right choice (was Re: How viable is Cocoa development?)
  • Next by Date: Re: Centering a view in an NSScrollView
  • Previous by thread: NSHTTPURLHandle bugs
  • Next by thread: Re: KCAddGenericPassword()
  • Index(es):
    • Date
    • Thread