Add error reporting to the MacOS port. #314
No reviewers
Labels
No labels
3rdparty
Android
API
Author does not respond
bsd
bug
build system/CI
ci-virtual-device
CMake
Contributions Welcome
Core
dependencies
device-specific
documentation
don't_merge
duplicate
enhancement
Example
Haiku
hidraw
hotplug
info required
invalid
libusb
macOS
Misc
Not an issue
question
Release
Test
Test GUI
Windows
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-libusb/hidapi!314
Loading…
Reference in a new issue
No description provided.
Delete branch "mac_error_messages"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Initial implementation of error messages for the macOS port.
Interface mostly copied from the linux port.
Messages probably need some love for the other errors being reported.
This is to resolve issue #310
this
__threadactually bugs me very much:we claim that it is thread safe, but imagine next scenario:
thread1:
hid_init()- successthread1:
hid_enumerat()- error happened and registeredthread2:
hid_enumerat()- error happened and registeredthread1:
hid_exit()-last_global_error_strfrom thread1 is freed, butlast_global_error_strfrom thread2 is leakedI'm sure the very same issue is present with
hidrawimplementation of the global erroryour intention with this PR is great, but I'd like to hear some ideas of how can we fix the global issues all together
I am not a threading expert, and only copied code from the other implementation from this code base.
Why is thread 2 allowed to run
hid_enumerate()without callinghid_init()How do we add
register_global_error(NULL);to apthread_cleanup_push?But it looks like that's the solution. In thread we need the cleanup_pop to have ability to clear the hid thread error.
It also looks like I might have missed adding the freeing of the device pointers on close of device
That is the design of the API.
hid_init()- is a global initialisation of the library.pthread_cleanup_pushmight not be enough, as it clears the resources at thread exit only, and we should come up with something athid_exit().I think we need to use
pthread_keyhere, unless someone has other ideas.Self-code-review is always a good thing.
After going thru the git history again, and trying to find a good solution,
I think the best approach would be to discard the faulty behavior introduced not so long ago (https://github.com/libusb/hidapi/pull/23) and don't make any thread-safety assumptions for
hid_error, i.e.: makelast_global_error_stra simplestaticvariable.Hi @hardkrash,
Are you still up to finish this PR?
I've started some changes for
hidrawbackend: https://github.com/libusb/hidapi/pull/428,those introduce a safe strategy for
hid_errorand allows to proceed with the implementation for other (this one) backends.#428 has been merged.
I took the liberty of updating the implementation:
I don't have a chance to test this well as of yet.
Additional core review is welcome.
I guess if any objections/improvements - we'll be fixing them in master.