Skip to content

Commit

Permalink
hotplug_libusb: fix cleanup for IFD_GENERATE_HOTPLUG
Browse files Browse the repository at this point in the history
If IFD_GENERATE_HOTPLUG is defined by all USB drivers:
    <key>ifdCapabilities</key>
    <string>0x00000001</string>

    <!-- Possible values for ifdCapabilities bits
    1: IFD_GENERATE_HOTPLUG
       plugging the reader calls pcscd \-\-hotplug

    Default value is 0x00000000
    -->

then the hotplug mechanism does not use polling to rescan the USB bus
but waits for pcscd to be called with "--hotplug" to rescan the USB bus
and serial configurations.

This case was not handled correctly on pcscd exit and the
HPEstablishUSBNotifications thread was not terminated.
  • Loading branch information
LudovicRousseau committed Apr 13, 2024
1 parent a53d65a commit bfcb434
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/hotplug_libusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,8 @@ static void * HPEstablishUSBNotifications(int pipefd[2])
}
while (read(rescan_pipe[0], &dummy, sizeof(dummy)) > 0)
{
if (AraKiriHotPlug)
break;
Log1(PCSC_LOG_INFO, "Reload serial configuration");
HPRescanUsbBus();
#ifdef USE_SERIAL
Expand Down Expand Up @@ -597,6 +599,8 @@ LONG HPSearchHotPluggables(const char * hpDirPath)
LONG HPStopHotPluggables(void)
{
AraKiriHotPlug = true;
HPReCheckSerialReaders();

if (rescan_pipe[1] >= 0)
{
close(rescan_pipe[1]);
Expand Down

0 comments on commit bfcb434

Please sign in to comment.