diff options
author | Greg Kaiser <gkaiser@google.com> | 2020-03-23 09:03:39 -0700 |
---|---|---|
committer | Greg Kaiser <gkaiser@google.com> | 2020-03-23 16:09:57 +0000 |
commit | f0f1d83624a8aafe402d00e14a83078b2f2c2471 (patch) | |
tree | 8624193d04f76733f405aad0d9d05f0b34942fb6 /cmds/statsd/src/shell/ShellSubscriber.cpp | |
parent | e39a7b6a800c9cf49c4ca60b1392d51eff21a738 (diff) |
ShellSubscriber: Avoid rollover bug
We initialize 'mToken' instead of leaving it uninitialized, making
it much less likely to rollover. In additional, we change our
check to inequality, to handle rollover if that were to happen.
There is the (theoretical) possibility of exactly 2^32 other
requests being claimed between our claim and our check. It's
assumed that is essentially impossible and not a concern.
Test: TreeHugger
Bug: 150619687
Change-Id: Iee303e05082a6b3b31ed546bd62d3afe67c771d8
Diffstat (limited to 'cmds/statsd/src/shell/ShellSubscriber.cpp')
-rw-r--r-- | cmds/statsd/src/shell/ShellSubscriber.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/cmds/statsd/src/shell/ShellSubscriber.cpp b/cmds/statsd/src/shell/ShellSubscriber.cpp index 6fa165475029..c677222f31eb 100644 --- a/cmds/statsd/src/shell/ShellSubscriber.cpp +++ b/cmds/statsd/src/shell/ShellSubscriber.cpp @@ -41,7 +41,7 @@ void ShellSubscriber::startNewSubscription(int in, int out, int timeoutSec) { // critical-section std::unique_lock<std::mutex> lock(mMutex); - if (myToken < mToken) { + if (myToken != mToken) { // Some other subscription has already come in. Stop. return; } |