diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2017-01-27 10:01:52 +0100 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2017-01-27 10:01:52 +0100 |
commit | 25cc8575da9a9b8bf60c64c8059cb5f73cc52e1d (patch) | |
tree | a9100c34073a73e0ed13d802df7deae5d9027ab6 /scd/scdaemon.c | |
parent | scd: Wake up the select when new USB scan. (diff) | |
download | gnupg2-25cc8575da9a9b8bf60c64c8059cb5f73cc52e1d.tar.xz gnupg2-25cc8575da9a9b8bf60c64c8059cb5f73cc52e1d.zip |
scd: Improve watching USB device removal.
* scd/apdu.c(struct reader_table_s): Add require_get_status.
(apdu_connect): Change return value meaning. Call apdu_reset here.
* scd/app.c (app_new_register): Add require_get_status.
(select_application): Use the return value of apdu_connect.
(scd_update_reader_status_file): Call update_fdset_for_usb with
checking all_have_intr_endp.
(app_list_start, app_list_finish): Remove.
* scd/ccid-driver.c (struct ccid_driver_s): Add transfer.
(intr_cb): Don't call libusb_transfer in this callback.
(ccid_require_get_status): New.
(do_close_reader): Call libusb_transfer here.
* scd/scdaemon.c (update_fdset_for_usb): Remove the first argument.
--
With Gnuk Token, it works fine as expected. With Gemalto reader,
intr_cb is not called when card is removed. So, the macro
LIBUSB_WORKS_EXPECTED_FOR_INTERRUPT_ENDP is not defined yet.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Diffstat (limited to 'scd/scdaemon.c')
-rw-r--r-- | scd/scdaemon.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/scd/scdaemon.c b/scd/scdaemon.c index 14e0b05f0..4ab0fcf9a 100644 --- a/scd/scdaemon.c +++ b/scd/scdaemon.c @@ -1202,15 +1202,14 @@ start_connection_thread (void *arg) void -update_fdset_for_usb (int scanned, int all_have_intr_endp) +update_fdset_for_usb (int all_have_intr_endp) { #ifdef HAVE_LIBUSB const struct libusb_pollfd **pfd_array = libusb_get_pollfds (NULL); const struct libusb_pollfd **p; #endif - if (scanned) - usb_all_have_intr_endp = all_have_intr_endp; + usb_all_have_intr_endp = all_have_intr_endp; FD_ZERO (&fdset); nfd = 0; @@ -1230,6 +1229,7 @@ update_fdset_for_usb (int scanned, int all_have_intr_endp) if (nfd < fd) nfd = fd; p++; + log_debug ("USB: add %d to fdset\n", fd); } libusb_free_pollfds (pfd_array); @@ -1238,8 +1238,7 @@ update_fdset_for_usb (int scanned, int all_have_intr_endp) /* Kick the select loop. */ write (notify_fd, "", 1); - log_debug ("update_fdset_for_usb (%d, %d): %d %lx\n", - scanned, all_have_intr_endp, nfd, fdset.fds_bits[0]); + log_debug ("update_fdset_for_usb (%d): %d\n", all_have_intr_endp, nfd); } static int @@ -1395,6 +1394,7 @@ handle_connections (void) char buf[256]; read (pipe_fd[0], buf, sizeof buf); + ret--; } if (listen_fd != -1 && FD_ISSET (listen_fd, &read_fdset)) @@ -1439,6 +1439,8 @@ handle_connections (void) if (ret) { struct timeval tv = {0, 0}; + + log_debug ("scd main: USB handle events\n"); libusb_handle_events_timeout_completed (NULL, &tv, NULL); } #endif |