Hello,

I have a strange behaviour in GNUStep. Before digging deeper, I wanted to know 
if anyone has a clue.

I have this piece of code:

- (BOOL)updateViaUrl:(NSString *)url /* returns YES on success */
              serial:(NSString *)serial
{
    NSMutableString *full_url = [[NSMutableString alloc]init];
    [full_url appendFormat:@"%@?serial=%@",url,[serial urlencode]];
    NSURL *u = [[NSURL alloc]initWithString:full_url];
    NSError *e= NULL;
    @autoreleasepool
    {
        @try
        {
    #ifdef __APPLE__
            NSData *data = [NSData dataWithContentsOfURL:u
                                             options:NSDataReadingUncached
                                               error:&e];
    #else
            NSData *data = [NSData dataWithContentsOfURL:u];
    #endif
            if((e==0) && (data.length > 0))
            {
                returnValue = YES;
            }
        }
        @catch(NSException *e)
        {
            NSLog(@"Exception while pulling URL %@",full_url);
            returnValue = NO;
        }
    }
    return returnValue;
}


This gets called in a background thread in regular intervalls. Its updating a 
server with some statistic by pushing some data over https://..

Here's how the process is created:


- (void)runSelectorInBackground:(SEL)aSelector
                     withObject:(id)anArgument
{
        UMObjectThreadStarter *ts = [[UMObjectThreadStarter alloc]init];
        ts.selector = aSelector;
        ts.obj      = anArgument;
        [NSThread detachNewThreadSelector:@selector(threadStarter:)
                                                         toTarget:self
                                                   withObject:ts];
}

(threadStarter: then calls above updateViaURL at some point)


What I have seen is that on gnustep it was producing a crash. This was caused 
by no autorelease pool being present as it was launched in a background thread.
@autoreleasepool {...}  fixed that crash. (On MacOS X it wasnt crashing).

Now I experience some busyloops in my application _sometimes_ and whenever I 
load it into the debugger I see that it is in dataWithContentsOfURL: call

To be noted is that the URL called could not be reachable intentionally  (no 
DNS, firewalls etc) or temporarely (no current coverage, routing issues)

For now I just disabled this code but I wondered if anyone has seen something 
similar and knows a quick workaround

Reply via email to