Is there some trick to getting NSURLConnection to work with an NSOperationQueue 
on iOS 5, and perhaps Lion but I haven't tried it there? It seems that it 
causes a deadlock every time just after the last delegate message has been sent 
(connectionDidFinishLoading:). The project is using ARC.

The connection is setup like this:

_connection = [[NSURLConnection alloc] initWithRequest:request delegate:self 
startImmediately:NO];
[_connection setDelegateQueue:_queue];
[_connection start];

The operation queue used is setup in this category method of NSOperationQueue

+ (NSOperationQueue*)URLConnectionQueue
{
        static NSOperationQueue* _S_operationQueue;
        static dispatch_once_t _S_once;
        
        dispatch_once(&_S_once, ^{
                _S_operationQueue = [[NSOperationQueue alloc] init];
                _S_operationQueue.name = 
@"com.falkor.URLConnectionQueuedLoading";
        });
        
        return _S_operationQueue;
}

The connection runs and finishes sending the connectionDidFinishLoading: 
message and then deadlocks on the thread that created it. Interestingly enough 
it appears that a runloop is still required to even start the connection when 
it's setup to use a NSOperationQueue for the delegate messages otherwise the 
connection is never started.

Thread 7 (process 22301):
#0  0x960f8b42 in select$DARWIN_EXTSN ()
#1  0x017107fb in __CFSocketManager ()
#2  0x97e9fed9 in _pthread_start ()
#3  0x97ea36de in thread_start ()

Thread 6 (process 22301):
#0  0x960f6c22 in mach_msg_trap ()
#1  0x960f61f6 in mach_msg ()
#2  0x0177c13a in __CFRunLoopServiceMachPort ()
#3  0x016df605 in __CFRunLoopRun ()
#4  0x016dedb4 in CFRunLoopRunSpecific ()
#5  0x016deccb in CFRunLoopRunInMode ()
#6  0x00e2de40 in +[NSURLConnection(Loader) _resourceLoadLoop:] ()
#7  0x00d3f4e6 in -[NSThread main] ()
#8  0x00d3f457 in __NSThread__main__ ()
#9  0x97e9fed9 in _pthread_start ()
#10 0x97ea36de in thread_start ()

Thread 5 (process 22301):
#0  0x960f8876 in __psynch_mutexwait ()
#1  0x97e9e6af in pthread_mutex_lock ()
#2  0x0216b7e1 in URLConnectionClient::cancelConnection ()
#3  0x0209cc0c in URLConnection::cancel ()
#4  0x0209cbf2 in CFURLConnectionCancel ()
#5  0x00e2fdca in -[NSURLConnectionInternalConnection _invalidate] ()
#6  0x00e2ed10 in __66-[NSURLConnectionInternal 
_withConnectionDisconnectFromConnection]_block_invoke_0 ()
#7  0x00e2ee94 in __65-[NSURLConnectionInternal 
_withConnectionAndDelegate:onlyActive:]_block_invoke_0 ()
#8  0x00d6b64e in -[NSBlockOperation main] ()
#9  0x00d641f7 in -[__NSOperationInternal start] ()
#10 0x00d63efa in -[NSOperation start] ()
#11 0x00df40bd in __block_global_6 ()
#12 0x02487445 in _dispatch_call_block_and_release ()
#13 0x024884e6 in _dispatch_worker_thread2 ()
#14 0x97ea1b24 in _pthread_wqthread ()
#15 0x97ea36fe in start_wqthread ()

Thread 4 (process 22301):
#0  0x960f6c22 in mach_msg_trap ()
#1  0x960f61f6 in mach_msg ()
#2  0x0177c13a in __CFRunLoopServiceMachPort ()
#3  0x016df605 in __CFRunLoopRun ()
#4  0x016dedb4 in CFRunLoopRunSpecific ()
#5  0x016deccb in CFRunLoopRunInMode ()
#6  0x057cd220 in RunWebThread ()
#7  0x97e9fed9 in _pthread_start ()
#8  0x97ea36de in thread_start ()

Thread 3 (process 22301):
#0  0x960f883e in __psynch_cvwait ()
#1  0x97ea3e21 in _pthread_cond_wait ()
#2  0x97e5442c in pthread_cond_wait$UNIX2003 ()
#3  0x00d7a8fc in -[__NSOperationInternal waitUntilFinished] ()
#4  0x00d7a85e in -[NSOperation waitUntilFinished] ()
#5  0x00e2ff0e in -[NSURLConnectionInternalConnection invokeForDelegate:] ()
#6  0x00e2ee4f in -[NSURLConnectionInternal 
_withConnectionAndDelegate:onlyActive:] ()
#7  0x00e2ecb0 in -[NSURLConnectionInternal 
_withConnectionDisconnectFromConnection] ()
#8  0x00d73fe2 in _NSURLConnectionReleaseClient ()
#9  0x0216b306 in URLConnectionClient::releaseClientLocked ()
#10 0x0209342d in URLConnectionClient::processEvents ()
#11 0x0216916b in non-virtual thunk to 
URLConnectionInstanceData::multiplexerClientPerform() ()
#12 0x02093137 in MultiplexerSource::perform ()
#13 0x0177c97f in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ ()
#14 0x016dfb73 in __CFRunLoopDoSources0 ()
#15 0x016df454 in __CFRunLoopRun ()
#16 0x016dedb4 in CFRunLoopRunSpecific ()
#17 0x016deccb in CFRunLoopRunInMode ()
#18 0x00d7341f in -[NSRunLoop(NSRunLoop) runMode:beforeDate:] ()
#19 0x0000e723 in -[FBLoginOperation main] (self=0xfa19a90, _cmd=0x166971a) at 
LoginOperation.m:142
#20 0x0000e542 in -[FBLoginOperation start] (self=0xfa19a90, _cmd=0x6aadf8b) at 
LoginOperation.m:127
#21 0x00df40bd in __block_global_6 ()
#22 0x02487445 in _dispatch_call_block_and_release ()
#23 0x024884e6 in _dispatch_worker_thread2 ()
#24 0x97ea1b24 in _pthread_wqthread ()
#25 0x97ea36fe in start_wqthread ()

Thread 2 (process 22301):
#0  0x960f990a in kevent ()
#1  0x02489373 in _dispatch_mgr_invoke ()
#2  0x02487cd0 in _dispatch_mgr_thread ()

Thread 1 (process 22301):
#0  0x960f6c22 in mach_msg_trap ()
#1  0x960f61f6 in mach_msg ()
#2  0x0177c13a in __CFRunLoopServiceMachPort ()
#3  0x016df580 in __CFRunLoopRun ()
#4  0x016dedb4 in CFRunLoopRunSpecific ()
#5  0x016deccb in CFRunLoopRunInMode ()
#6  0x024b8879 in GSEventRunModal ()
#7  0x024b893e in GSEventRun ()
#8  0x0043ba9b in UIApplicationMain ()
#9  0x00002336 in main (argc=1, argv=0xbffff668) at main.mm:16

--
Michael_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to