lloydsargent / BlackRaccoon

IOS FTP Client Code
102 stars 37 forks source link

Timeout error if not called from main thread #22

Closed Frugghi closed 11 years ago

Frugghi commented 11 years ago

Hi, If I call the start method from gcd global queue the BRRequest fails and return a timeout error. Same code from main queue works fine.

lloydsargent commented 11 years ago

I've never tested this code with anything but the main queue. The problem is there is much in iOS that is not thread-safe (and it changes).

However, if I were to guess I would say the need for a run loop is the primary issue (it is needed for the BRStreamInfo class).

Is there a reason you need to put ftp download in a separate thread?

Frugghi commented 11 years ago

Yes, it's definitely run loop "fault". Anyway I had no reason to use the code from a separate thread but I spent an hour or so debugging the issue.

You should mention it in the documentation or call scheduleInRunLoop: and open from main queue.

lloydsargent commented 11 years ago

That's a good point. I never anticipated it being used from another thread considering it's size, the amount of time FTP takes, and the "uncertainty factor" - I like my threads small, quick, and (hopefully) predictable.

Thanks for mentioning it. At a MINIMUM I will mention that any usage in a secondary thread is up to the user to define and debug. Fortunately, the current design is such that it doesn't impact the GUI - which is the only reason I would ever opt for using GCD.