LudovicRousseau / PCSC

pcsc-lite: PC/SC implementation
https://pcsclite.apdu.fr/
Other
258 stars 107 forks source link

Deterministically wait on hotplug_libusb shutdown #174

Closed emaxx-google closed 5 months ago

emaxx-google commented 5 months ago

Change HPStopHotPluggables() to actually wait until the background hotplug thread exits.

This makes sure that the hotplug mechanism doesn't continue working throughout the daemon's shutdown process, and hence use-after-frees (if a reader is added/removed after the readerfactory is shut down), memory leaks etc. are prevented.

Note: this is expected to make the "SYS_Sleep(1)" trick in pcscdaemon.c unnecessary, replacing it with a more reliable alternative. We don't delete the sleep in the same commit in case it turns out to be crucial for some other reason.

emaxx-google commented 5 months ago

173 is a precondition for this.

LudovicRousseau commented 5 months ago

Merged Thanks