Commit bdf562c
committed
util/agents/usb_hid_relay: fix concurrent access
Since c9fc5bf, it was no longer possible to use the same USB relay
device from multiple labgrid processes, as the USB device was kept open
and claimed.
To fix this, we use a context manager which first claims the USB
interface (with retry while busy) and releases it after the transaction.
With this fix, multiple processes can toggle outputs in a busy loop
without causing 'USBError(16, 'Resource busy')' failures.
Fixes: c9fc5bf ("labgrid/util/agents/usb_hid_relay: keep the USB device open")
Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
(cherry picked from commit 659f7df)
Signed-off-by: Jan Luebbe <jlu@pengutronix.de>1 parent 04f4655 commit bdf562c
1 file changed
Lines changed: 36 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
| |||
26 | 30 | | |
27 | 31 | | |
28 | 32 | | |
29 | | - | |
30 | | - | |
| 33 | + | |
| 34 | + | |
31 | 35 | | |
32 | | - | |
33 | | - | |
| 36 | + | |
| 37 | + | |
34 | 38 | | |
35 | 39 | | |
36 | 40 | | |
37 | 41 | | |
38 | 42 | | |
39 | 43 | | |
40 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
41 | 62 | | |
42 | 63 | | |
43 | 64 | | |
| |||
48 | 69 | | |
49 | 70 | | |
50 | 71 | | |
51 | | - | |
| 72 | + | |
52 | 73 | | |
53 | 74 | | |
54 | 75 | | |
| |||
59 | 80 | | |
60 | 81 | | |
61 | 82 | | |
62 | | - | |
| 83 | + | |
63 | 84 | | |
64 | 85 | | |
65 | 86 | | |
| |||
68 | 89 | | |
69 | 90 | | |
70 | 91 | | |
71 | | - | |
| 92 | + | |
72 | 93 | | |
73 | 94 | | |
74 | 95 | | |
75 | 96 | | |
76 | | - | |
77 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
78 | 104 | | |
79 | 105 | | |
80 | 106 | | |
| |||
0 commit comments