Commit b890103
committed
emcy: Fix maximum timeout logic errors in EmcyConsumer.wait().
If an EMCY package was received, but filtered out by the emcy_code
matching, the condition waiting is started again with the same
timeout. Thus the actual maximum waiting time is not correctly
limited to the given argument, as the docstring promises. Track the
remaining time until the initial deadline instead, as basis for the
condition wait.
Further, spurious wake-ups from the condition wait on the OS level are
not handled correctly. The threading.Condition docs explicitly
recommend checking the shared state (number of logged entries in this
case) in the while loop, because the wait() call may abort early. The
current code assumes that this necessarily indicates a timeout,
without checking the actually passed time again. Reorder the check
against end_time in the loop to avoid this.1 parent 9aab2d4 commit b890103
1 file changed
Lines changed: 9 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
73 | 76 | | |
74 | | - | |
75 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
76 | 82 | | |
77 | 83 | | |
78 | 84 | | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | 85 | | |
83 | 86 | | |
84 | 87 | | |
| |||
0 commit comments