dbus-sensors: nvmesensor: add 1s timeout for mi worker cv.wait

The main thread `workerCv.notify_all` function may be called
when mi worker thread is not in waiting state because there is a
small time window between the `io.run()` and the
`std::unique_lock<std::mutex> lock(mtx)` statement.

This corner case is not a big issue after a subsystem is fully
started because there is periodical health poll to notify the
mi worker thread.  However, for the `Status::Initializing` state,
this corner case will cause mi worker thread never wake up to
execute handler.

There exist many solutions to fix this problem. The simplest (one line)
fix should be adding 1 second timeout for the `cv.wait`.

Tested:
Reproduce script: https://paste.googleplex.com/5229001098919936
Before the fix, if we keep restarting nvmesensor for hundreds of loops,
we will find that at least one subsystem keeps on printing:

  subsystem is intiatilzing, cancel the health poll
  processing health data has been cancelled

After the fix, the same restarting test passed hundreds of loops without
printing the message above.

Google-Bug-Id: 310663382
Change-Id: I6493e87d1ee555a8fba581470da503b0c67bec27
Signed-off-by: Jinliang Wang <jinliangw@google.com>
(cherry picked from commit 5e4bce1c1001cb6a73007acf864a80cc85519693)
2 files changed
tree: a82c327d3094435a81265a7e5fff619000d3bd58
  1. conf/
  2. dynamic-layers/
  3. recipes-bsp/
  4. recipes-connectivity/
  5. recipes-core/
  6. recipes-devtools/
  7. recipes-extended/
  8. recipes-google/
  9. recipes-kernel/
  10. recipes-phosphor/
  11. LICENSE
  12. README.md
README.md

meta-gbmc-staging

This repository contains additions to the openbmc/meta-google layer that are not yet ready for OpenBMC inclusion.

How to use this layer

  1. Clone openbmc/openbmc from GitHub.
  2. Clone this layer from GitHub into a subdirectory of openbmc.