Repository navigation
Conversation
|
btw. I caught this because the libfprint CI tests suddenly started to fail (after the Fedora update to 1.0.25 which includes #1058). For these tests, we use umockdev, which allows us to replay (or emulate) arbitrary USB transfers. What umockdev offers specifically is:
Now, I was wondering how big the interest is in having umockdev based tests inside libusb proper. Note that there is the caveat that the |
|
We'd sure love to have some automatic testing with device emulation. |
Yes, for sure that will be very good. |
|
Eeks. This breaks the synchronous API. It uses Not sure what to do about that right now. The straight forward but ugly thing would to track all transfers in dev_handle that were not free'ed yet. Then one can clear dev_handle in device close. |
|
Or, well, we change the check in |
6428090 to
2845a87
Compare
|
OK, here is the fancy patch, which ensures that The simple version is to just replace Another alternative could be to keep the previous patch but change the logic in |
2845a87 to
1cb11c5
Compare
1cb11c5 to
d05c436
Compare
transfer->dev_handle currently has the behaviour that it will be unset if the device is closed. The sync API uses this fact to catch an error case. In other cases, transfer->dev_handle will keep its value, which means that if the transfer lives longer than the device handle, the pointer becomes invalid. The transfer does however keep a reference to the device, which owns the pointer to the context. As such, we can track this reference internal to the transfer, and it is set while the transfer is in-flight. With this, switch the logging infrastructure to use itransfer->dev->ctx while checking that itransfer->dev is non-NULL. Note that this was a regression caused by 6cae9c6 ("core: update usbi_dbg to take the context as an argument"), specifically when resolving the context while freeing a transfer after closing a device. Note that the transfer will now keep a reference to the device until it is free'ed. This allows it to use the correct context for logging even in libusb_free_transfer. The alternative to all this would be to just explicitly pass NULL to the log handler in libusb_free_transfer. Closes: libusb#1038
d05c436 to
010691f
Compare
The log handler in libusb_free_transfer now tries to get the context. However, that requires a pointer to the device, which may either be NULL already (
do_closeincore.cdoes this), or may currently even be an invalid pointer if the device for a non in-flight transfer was closed.This PR fixes both issues.