1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-06-01 22:28:02 +02:00

scd: Add npth_unprotect/npth_protect for blocking operations.

* scd/ccid-driver.c (ccid_open_usb_reader): Name the thread.
(ccid_vendor_specific_setup, ccid_open_usb_reader): Wrap
blocking operations by npth_unprotect/npth_protect.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2022-08-25 13:13:11 +09:00 committed by Werner Koch
parent 14ccabe7f8
commit e1169e8f8a
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -1325,7 +1325,13 @@ ccid_vendor_specific_setup (ccid_driver_t handle)
{ {
if (handle->id_vendor == VENDOR_SCM && handle->id_product == SCM_SPR532) if (handle->id_vendor == VENDOR_SCM && handle->id_product == SCM_SPR532)
{ {
#ifdef USE_NPTH
npth_unprotect ();
#endif
libusb_clear_halt (handle->idev, handle->ep_intr); libusb_clear_halt (handle->idev, handle->ep_intr);
#ifdef USE_NPTH
npth_protect ();
#endif
} }
return 0; return 0;
} }
@ -1705,6 +1711,7 @@ ccid_open_usb_reader (const char *spec_reader_name,
*handle = NULL; *handle = NULL;
return err; return err;
} }
npth_setname_np (thread, "ccid_usb_thread");
npth_attr_destroy (&tattr); npth_attr_destroy (&tattr);
} }
@ -1749,9 +1756,15 @@ ccid_open_usb_reader (const char *spec_reader_name,
goto leave; goto leave;
} }
#ifdef USE_NPTH
npth_unprotect ();
#endif
rc = libusb_claim_interface (idev, ifc_no); rc = libusb_claim_interface (idev, ifc_no);
if (rc) if (rc)
{ {
#ifdef USE_NPTH
npth_protect ();
#endif
DEBUGOUT_1 ("usb_claim_interface failed: %d\n", rc); DEBUGOUT_1 ("usb_claim_interface failed: %d\n", rc);
rc = map_libusb_error (rc); rc = map_libusb_error (rc);
goto leave; goto leave;
@ -1761,11 +1774,18 @@ ccid_open_usb_reader (const char *spec_reader_name,
rc = libusb_set_interface_alt_setting (idev, ifc_no, set_no); rc = libusb_set_interface_alt_setting (idev, ifc_no, set_no);
if (rc) if (rc)
{ {
#ifdef USE_NPTH
npth_protect ();
#endif
DEBUGOUT_1 ("usb_set_interface_alt_setting failed: %d\n", rc); DEBUGOUT_1 ("usb_set_interface_alt_setting failed: %d\n", rc);
rc = map_libusb_error (rc); rc = map_libusb_error (rc);
goto leave; goto leave;
} }
#ifdef USE_NPTH
npth_protect ();
#endif
rc = ccid_vendor_specific_init (*handle); rc = ccid_vendor_specific_init (*handle);
leave: leave: