pokeb / asi-http-request

Easy to use CFNetwork wrapper for HTTP requests, Objective-C, Mac OS X and iPhone
http://allseeing-i.com/ASIHTTPRequest
Other
5.77k stars 1.41k forks source link

bad access after canceling synchronous ASIHTTPRequest #272

Open dzianis-vasileuski opened 13 years ago

dzianis-vasileuski commented 13 years ago

cancel method uses background thread (returned by threadForRequest), but synchronous thread executed in other thread. When we cancel synchronous request we sometimes get a bad access crash.

NSZombie print: *\ -[CFWriteStream hasSpaceAvailable]: message sent to deallocated instance 0x35ef5020

Other issue: Do we need @synchronized() in threadForRequest ? We can lunch request from multiple threads. This issue relative to code in ASIHTTPRequest:

pragma mark threading behaviour

// In the default implementation, all requests run in a single background thread // Advanced users only: Override this method in a subclass for a different threading behaviour // Eg: return [NSThread mainThread] to run all requests in the main thread // Alternatively, you can create a thread on demand, or manage a pool of threads // Threads returned by this method will need to run the runloop in default mode (eg CFRunLoopRun()) // Requests will stop the runloop when they complete // If you have multiple requests sharing the thread or you want to re-use the thread, you'll need to restart the runloop

…….

Ricardo1980 commented 12 years ago

Did you solve this issue?

dzianis-vasileuski commented 12 years ago

No. I just avoid using cancel method on synchronous request.

futuretap commented 12 years ago

Would love to know a solution for this. Not sure but this might be related to #104.