Commit bd9997b
authored
sensors: make getsensoridentity/getsensorshort thread-safe (fix garbage names under concurrent callers) (#183)
* sensors: serialise getsensor* and stop getsensorid falling through
getsensoridentity()/getsensorshort() drive i2c detection through the global
i2c_adapter_nr and format into one shared static buffer, unlocked; getsensorid()
also fell off the end with no return when every bus failed. Concurrent callers
stomped the adapter mid-probe and tore the buffer, and the missing return let an
all-fail probe format an uninitialised ctx — together producing binary-garbage
sensor names. Serialise detect+format under one mutex and return false on the
exhausted path.
* build: link Threads for the sensor-detection mutex
sensors.c now uses pthread_mutex_*, the first real pthread use in the tree, but
the targets only linked m. It happens to resolve on musl and glibc >= 2.34
(pthread folded into libc) yet fails to link on older glibc and uClibc.
find_package(Threads REQUIRED) and link Threads::Threads on ipchw (interface, so
ipcinfo and external consumers of libipchw pull it in) and on ipctool.1 parent f6e64a1 commit bd9997b
2 files changed
Lines changed: 39 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
7 | 12 | | |
8 | 13 | | |
9 | 14 | | |
| |||
181 | 186 | | |
182 | 187 | | |
183 | 188 | | |
184 | | - | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
185 | 192 | | |
186 | 193 | | |
187 | 194 | | |
188 | 195 | | |
189 | 196 | | |
190 | | - | |
| 197 | + | |
191 | 198 | | |
192 | 199 | | |
193 | 200 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1245 | 1245 | | |
1246 | 1246 | | |
1247 | 1247 | | |
1248 | | - | |
1249 | | - | |
1250 | 1248 | | |
| 1249 | + | |
1251 | 1250 | | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
1252 | 1255 | | |
1253 | 1256 | | |
1254 | 1257 | | |
| |||
1287 | 1290 | | |
1288 | 1291 | | |
1289 | 1292 | | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
1290 | 1300 | | |
1291 | 1301 | | |
| 1302 | + | |
1292 | 1303 | | |
1293 | | - | |
1294 | | - | |
1295 | | - | |
1296 | | - | |
1297 | | - | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
1298 | 1312 | | |
1299 | 1313 | | |
1300 | 1314 | | |
| 1315 | + | |
1301 | 1316 | | |
1302 | | - | |
1303 | | - | |
1304 | | - | |
1305 | | - | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
1306 | 1325 | | |
0 commit comments