• spiiroin's avatar
    [usb-moded] Move synchronous mode switch to worker thread. Fixes JB#42757 · 57d404a3
    spiiroin authored
    Mode switching in usb-moded is done via synchronous ipc / otherwise
    blocking operations - which makes usb-moded mainloop unable to process
    for example udev events / dbus requests from clients during the swich
    and causes potentially stale events to be seen after the mode switch.
    Separate mode selection from mode activation so that the latter is
    executed from worker thread.
    Distribute existing code in manner that makes the selection vs activation,
    or mainloop / worker thread separation more apparent:
    - control.c: Mode selection logic
    - worker.c:  Mode activation logic
    And move miscellaneous functions that have accumulated into the main
    usb-moded module to:
    - common.c:  Generic helper functions
    - sigpipe.c: Asynchronous signal trapping
    Rename all moved functions so that they still have prefix indicating the
    containing module.
    Refuse synchronous sleeps in order to terminate ongoing mode switch
    if udev events / other inputs invalidate the target of transition.
    Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
usb_moded-sigpipe.h 989 Bytes