box/box-ios-sdk-v2 — pull request #36 by lopopolo (2013-10-01 08:43:42+00:00)
Title: Under high load, BoxAPIOperations throw assertion failures on start

The executeOperation method in BoxAPIOperation.m throws an assertion
failure if the method runs and the operation is not ready.

BOXAssertFail(@"Operation was not ready but start was called");

This can happen if a dependency is added to the operation between
the time start is called and executeOperation runs on the API
Operation Thread.

* executeOperation is called asynchronously from operation start
* OAuth2 operations are added as dependencies for *all* operations in
the queue, including those that are already executing
* There is no coordination between operations starting and operation
dependencies being added.

Proposed solution: Add a class-level lock to BoxAPIOperation.

* All operations should acquire this lock immediately in start.
* The BoxAPIQueueManagers should acquire this lock before adding
OAuth2Operation dependencies.
* The BoxAPIQueueManagers should only add dependencies to operations
that are not executing.