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 d65f03ce6549a6be9cb0f373460a14bcca689fed)
2 files changed
tree: caa5dcd1c32c595fa084f0d665521e6485d55c9f
  1. conf/
  2. dynamic-layers/
  3. meta-nuvoton-npcm8xx/
  4. recipes-bsp/
  5. recipes-connectivity/
  6. recipes-core/
  7. recipes-devtools/
  8. recipes-extended/
  9. recipes-google/
  10. recipes-kernel/
  11. recipes-phosphor/
  12. recipes-support/
  13. LICENSE
  14. 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.