aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Source/Remote
diff options
context:
space:
mode:
authorGravatar Sebastian Schmidt <mrschmidt@google.com>2017-11-30 13:28:36 -0800
committerGravatar Sebastian Schmidt <mrschmidt@google.com>2017-11-30 13:29:26 -0800
commitd200fe09efaa57ed7e014e76d1bed52992f7ebc5 (patch)
tree1958b6acde6fe1b94506d9498119691380692893 /Firestore/Source/Remote
parentdf76451b3101c47865ccd5721c96a37ca8c8fa70 (diff)
Checking for stream close in handleStreamClose
Diffstat (limited to 'Firestore/Source/Remote')
-rw-r--r--Firestore/Source/Remote/FSTStream.m13
1 files changed, 8 insertions, 5 deletions
diff --git a/Firestore/Source/Remote/FSTStream.m b/Firestore/Source/Remote/FSTStream.m
index 9a780e5..ac51cb9 100644
--- a/Firestore/Source/Remote/FSTStream.m
+++ b/Firestore/Source/Remote/FSTStream.m
@@ -343,14 +343,13 @@ static const NSTimeInterval kIdleTimeout = 60.0;
- (void)closeWithFinalState:(FSTStreamState)finalState error:(nullable NSError *)error {
FSTAssert(finalState == FSTStreamStateError || error == nil,
@"Can't provide an error when not in an error state.");
-
- [self.workerDispatchQueue verifyIsCurrentQueue];
- [self cancelIdleCheck];
-
FSTAssert(self.delegate,
@"closeWithFinalState should only be called for a started stream that has an active "
@"delegate.");
+ [self.workerDispatchQueue verifyIsCurrentQueue];
+ [self cancelIdleCheck];
+
if (finalState != FSTStreamStateError) {
// If this is an intentional close ensure we don't delay our next connection attempt.
[self.backoff reset];
@@ -516,7 +515,11 @@ static const NSTimeInterval kIdleTimeout = 60.0;
*/
- (void)handleStreamClose:(nullable NSError *)error {
FSTLog(@"%@ %p close: %@", NSStringFromClass([self class]), (__bridge void *)self, error);
- FSTAssert([self isStarted], @"Can't handle server close in non-started state.");
+
+ if (![self isStarted]) { // The stream could have already been closed by the idle close timer.
+ FSTLog(@"%@ Ignoring server close for already closed stream.", NSStringFromClass([self class]));
+ return;
+ }
// In theory the stream could close cleanly, however, in our current model we never expect this
// to happen because if we stop a stream ourselves, this callback will never be called. To