Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a subtle push hook race in client shutdown.
Prior to this change, shortly after a client is closed it is possible that a queued push notification from the server that arrived before the close will have been dequeued, and then delivered to the OnNotify hook while the client is waiting to exit. In that case, the Close method may return before the hook is invoked. To avoid this scenario, ensure that delivery also gates shutdown, converting the done channel into a wait group. This case is tricky to test explicitly; I noticed it because of a very rare flake in the test for OnNotify itself. This change fixes the flake even for -count=1000, but I did not add a new test for this condition yet. This bug would only affect clients using OnNotify, and expecting hooks to have finished their work by the time Close returns (as the test does). That is now true, but was not in rare cases before.
- Loading branch information