Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Hotplug implementation #674

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft

RFC: Hotplug implementation #674

wants to merge 10 commits into from

Commits on May 1, 2023

  1. hotplug: Add ability to register device connection/disconnection call…

    …back (#299)
    
    - initial API;
    - Windows backend implementation;
    DJm00n authored May 1, 2023
    Configuration menu
    Copy the full SHA
    1b0b6ac View commit details
    Browse the repository at this point in the history

Commits on Mar 11, 2024

  1. Merge branch 'master' into connection-callback

    - fix merge conflict
    - fix indentation in a few places
    Youw committed Mar 11, 2024
    Configuration menu
    Copy the full SHA
    79a3516 View commit details
    Browse the repository at this point in the history

Commits on Apr 6, 2024

  1. Configuration menu
    Copy the full SHA
    ce92386 View commit details
    Browse the repository at this point in the history
  2. Connection callback: add stubs for netbsd (#668)

    * netbsd hotplug stubs
    
    * Make cygwin happy (fix copied from libusb)
    k1-801 authored Apr 6, 2024
    Configuration menu
    Copy the full SHA
    c3a2775 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    60b40d9 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    4537833 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    4f73d1f View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    cfed154 View commit details
    Browse the repository at this point in the history

Commits on Aug 20, 2024

  1. Configuration menu
    Copy the full SHA
    b6606ca View commit details
    Browse the repository at this point in the history

Commits on Sep 6, 2024

  1. Fix possible deadlock in Connection-callback feature (#676)

    Fix the possible issues that happen when a register or de-register call is made from inside a callback. The way it works is the same for all platforms and is described below.
    
    Resolves: #673 
    
    1) The mutex is made recursive, so it can be locked by the same thread multiple times
    2) `mutex_ready` kept intact, added 2 more flags, `mutex_in_use` and `cb_list_dirty`.
    3) When the `mitex_in_use` flag is set, the Deregister call is no longer allowed to immediately remove any callbacks from the list. Instead, the `events` field in the callback is set to 0, which makes it "invalid", as it will no longer match any events, and the `cb_list_dirty` flag is set to 1 to indicate that the list needs to be checked for invalid events later.
    4) When a callback returns a non-zero value, indicating that the callback is to be disarmed and removed from the list, it is marked in the same manner until the processing finishes (unless the callback was called directly by the Register call, in which case it's return value is ignored on purpose)
    5) After all the callbacks are processed, if `cb_list_dirty` flag is set, the list of callbacks is checked for any callbacks marked for removal (`events` field set to 0), and those are only removed after all the processing is finished.
    6) The Register call is allowed to register callbacks, as it causes no issues so long as the mutex it locks is recursive
    7) Since the Register call can also call the new callback if `HID_API_HOTPLUG_ENUMERATE` is specified, `mutex_in_use` flag is set to prevent callback removal in that new callback.
    8) The return value of any callbacks called for pre-existing devices is still ignored as per documentation and does not mark them invalid.
    k1-801 authored Sep 6, 2024
    Configuration menu
    Copy the full SHA
    da500c6 View commit details
    Browse the repository at this point in the history