diff options
author | Gil <mcg@google.com> | 2018-03-13 14:19:15 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-13 14:19:15 -0700 |
commit | d4d73ea53ecdf1e8ade3d00921419645dd5d66f7 (patch) | |
tree | be3c51c202acd5d1fa0a40e330224b90fd67f38d /Firestore/Example/Tests/Integration | |
parent | 687e8d768db7ea01219000ab25b43f524cc530ab (diff) |
Defend against users making API calls during deinit (#863)
Track operation in progress FSTDispatchQueue
... and allow dispatchAsync onto the worker queue even from the same
queue if an operation is not in progress. Fixes #753.
This fixes a corner case that happens when users pass us an object and
we retain that object in a block submitted to the worker queue for
processing. Users are not obligated to retain that object themselves.
This can lead to the object's destructor (or dealloc or deinit) being
called on the Firestore worker thread. If that destructor makes
Firestore API calls (most likely ListenerRegistration.remove but any are
possible) this will trigger the assertion.
Diffstat (limited to 'Firestore/Example/Tests/Integration')
-rw-r--r-- | Firestore/Example/Tests/Integration/FSTStreamTests.mm | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Firestore/Example/Tests/Integration/FSTStreamTests.mm b/Firestore/Example/Tests/Integration/FSTStreamTests.mm index 6550368..7e37913 100644 --- a/Firestore/Example/Tests/Integration/FSTStreamTests.mm +++ b/Firestore/Example/Tests/Integration/FSTStreamTests.mm @@ -243,9 +243,9 @@ using firebase::firestore::model::DatabaseId; }]; // Writing before the handshake should throw - dispatch_sync(_testQueue, ^{ + [_workerDispatchQueue dispatchSync:^{ XCTAssertThrows([writeStream writeMutations:_mutations]); - }); + }]; [_delegate awaitNotificationFromBlock:^{ [writeStream writeHandshake]; @@ -285,9 +285,9 @@ using firebase::firestore::model::DatabaseId; [_workerDispatchQueue runDelayedCallbacksUntil:FSTTimerIDWriteStreamIdle]; - dispatch_sync(_testQueue, ^{ + [_workerDispatchQueue dispatchSync:^{ XCTAssertFalse([writeStream isOpen]); - }); + }]; [self verifyDelegateObservedStates:@[ @"writeStreamDidOpen", @"writeStreamDidCompleteHandshake", @"writeStreamWasInterrupted" @@ -315,9 +315,9 @@ using firebase::firestore::model::DatabaseId; [_workerDispatchQueue containsDelayedCallbackWithTimerID:FSTTimerIDWriteStreamIdle]); }]; - dispatch_sync(_testQueue, ^{ + [_workerDispatchQueue dispatchSync:^{ XCTAssertTrue([writeStream isOpen]); - }); + }]; [self verifyDelegateObservedStates:@[ @"writeStreamDidOpen", @"writeStreamDidCompleteHandshake", |