FSNetworking icon indicating copy to clipboard operation
FSNetworking copied to clipboard

Race condition in FSNConnection

Open vladimirnp opened this issue 12 years ago • 1 comments

failWithError: is not designed to be called more than once, but in our case it is sometimes called twice: when the internet connectivity dies, and when UIApplication decides to run 'fireExpirationHandler'.

Presumably, 'endBackgroundTask' should prevent this from happening, but the first time failWithError: is called, 'complete' is enqueued on the run loop, and may be called only after the second call to failWithError:. Hence the race condition.

vladimirnp avatar Jan 15 '13 10:01 vladimirnp

Thanks for the report; I haven't looked into it but this does sound like a real problem. Ideally failWithError would be idempotent but we have to be careful about the ref-counting semantics, because failWithError can cause the connection instance to be released.

gwk avatar Feb 05 '13 21:02 gwk