Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for b/74749605: Cancel pending backoff operations when closing streams. #564

Merged
merged 2 commits into from
Mar 14, 2018

Conversation

mikelehen
Copy link
Contributor

No description provided.

Copy link
Contributor

@wilhuff wilhuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty much LGTM with some nits

@@ -316,6 +316,9 @@ export abstract class PersistentStream<

this.cancelIdleCheck();

// Ensure we don't leave a pending backoff operation queued.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment can move above the idle cancel and cover both:

// Ensure we don't leave pending timer-based operations queued.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrm. I had trouble creating a unified comment that I didn't feel was overly general or misleading, so instead I just commented both of them separately.

FWIW- the idle timer will only be active if the stream is currently connected when close() is called, and the backoff timer will only be active if the stream is not currently connected when close() is called.

@@ -316,6 +316,9 @@ export abstract class PersistentStream<

this.cancelIdleCheck();

// Ensure we don't leave a pending backoff operation queued.
this.backoff.cancel();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a little weird that cancelling the idle and backoff timers look different. Is there any way to make these uniform? I suppose this happens because the backoff timer is held within the backoff object but the idle timer is held directly?

I think this may be non-actionable, but mentioning it anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

acknowledged.

// Stream can be stopped while waiting for backoff to complete.
return;
}
assert(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Man am I gun-shy about this assertion. I'm somewhat in favor of just leaving the old behavior in place to keep this consistent with the other callbacks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah... I am torn between being as strict as possible with our state transitions vs being defensive. I mostly changed it to an assert, since as-is it's basically dead code.

I put it back though and just tweaked the comment.

Copy link
Contributor Author

@mikelehen mikelehen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tweaked comments and put the defensive state check back. Let me know what you think.

@@ -316,6 +316,9 @@ export abstract class PersistentStream<

this.cancelIdleCheck();

// Ensure we don't leave a pending backoff operation queued.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrm. I had trouble creating a unified comment that I didn't feel was overly general or misleading, so instead I just commented both of them separately.

FWIW- the idle timer will only be active if the stream is currently connected when close() is called, and the backoff timer will only be active if the stream is not currently connected when close() is called.

@@ -316,6 +316,9 @@ export abstract class PersistentStream<

this.cancelIdleCheck();

// Ensure we don't leave a pending backoff operation queued.
this.backoff.cancel();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

acknowledged.

// Stream can be stopped while waiting for backoff to complete.
return;
}
assert(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah... I am torn between being as strict as possible with our state transitions vs being defensive. I mostly changed it to an assert, since as-is it's basically dead code.

I put it back though and just tweaked the comment.

Copy link
Contributor

@wilhuff wilhuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mikelehen mikelehen merged commit b949d81 into master Mar 14, 2018
@mikelehen mikelehen deleted the mikelehen/fix-user-change-while-offline branch March 14, 2018 23:22
mikelehen pushed a commit to firebase/firebase-ios-sdk that referenced this pull request Mar 15, 2018
mikelehen pushed a commit to firebase/firebase-ios-sdk that referenced this pull request Mar 21, 2018
mikelehen added a commit to firebase/firebase-ios-sdk that referenced this pull request Mar 21, 2018
minafarid pushed a commit to minafarid/firebase-ios-sdk that referenced this pull request Jun 6, 2018
@firebase firebase locked and limited conversation to collaborators Oct 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants