tim-balloon / TIMflight

Flight MCP repo
0 stars 0 forks source link

chrgctrl unnecessary statics #34

Open evanmayer opened 1 year ago

evanmayer commented 1 year ago

Describe the bug

chrgctrl.c: Because have_warned_connect is shared between two threads (1 for each battery charge controller), if both charge controllers are unreachable, we will only warn about one missing. The warning will only be issued from the thread that gets to the charge controller comm check first, so it's also kind of a race condition.

To Reproduce Steps to reproduce the behavior:

  1. Ensure all charge controllers are disconnected from the network
  2. Start mcp: sudo ./mcp -x | grep ctrl
  3. Observe only 1 warning, either for 192.168.1.253 or 192.168.1.252, and that it varies from run to run.

Expected behavior One one-time warning for each disconnected charge controller. Potential fix: remove the static keyword from have_warned_connect and have_warned_error too.

Environment info (please complete the following information):