summaryrefslogtreecommitdiffstats
path: root/scd/scdaemon.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2021-04-28 18:19:33 +0200
committerWerner Koch <wk@gnupg.org>2021-04-28 18:21:56 +0200
commitbb8e3996e44f4f057f0771b9b72c89feae00f1b1 (patch)
tree4e6d9985f2560cb6812b0f700ad0b22bdbc3832c /scd/scdaemon.c
parentbuild: Allow running sign-release target from the dist dir. (diff)
downloadgnupg2-bb8e3996e44f4f057f0771b9b72c89feae00f1b1.tar.xz
gnupg2-bb8e3996e44f4f057f0771b9b72c89feae00f1b1.zip
scd: Fix problem with reader list becoming empty.
* scd/apdu.c (close_pcsc_reader): Do not decrement refcount if already zero. Always release context if or becomes zero. (apdu_dev_list_start): Unlock prior to close_pcsc_reader. For PC/SC increment the count. Always release the lock. (apdu_dev_list_finish): No more unlocking. Use close_pcsc_reader instead of code duplication. * scd/apdu.c (pcsc_error_string): Add an error code. * scd/scdaemon.c (scd_kick_the_loop): Fix a diagnostic. -- There was an obvious bug in that the pcsc.count could go below zero and thus there was no chance to get the context release. Releasing and recreating the context is at least under Windows important to get rit of the PCSC_E_SERVICE_STOPPED. Also removes a potential problem in holding the reader_table_lock between calls to apdu_dev_list_start apdu_dev_list_finish. There is no need for this. Instead we bump the pcsc.count. The reader_table_lock strategy should be reviewed; we may be able to remove it. Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to '')
-rw-r--r--scd/scdaemon.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/scd/scdaemon.c b/scd/scdaemon.c
index 60d68c26a..da1f21d1f 100644
--- a/scd/scdaemon.c
+++ b/scd/scdaemon.c
@@ -1231,7 +1231,7 @@ scd_kick_the_loop (void)
#else
int ret = kill (main_thread_pid, SIGCONT);
if (ret < 0)
- log_error ("SetEvent for scd_kick_the_loop failed: %s\n",
+ log_error ("sending signal for scd_kick_the_loop failed: %s\n",
gpg_strerror (gpg_error_from_syserror ()));
#endif
}
@@ -1287,6 +1287,8 @@ handle_connections (int listen_fd)
events[0] = the_event = INVALID_HANDLE_VALUE;
events[1] = INVALID_HANDLE_VALUE;
+ /* Create event for manual reset, initially non-signaled. Make it
+ * waitable and inheritable. */
h = CreateEvent (&sa, TRUE, FALSE, NULL);
if (!h)
log_error ("can't create scd event: %s\n", w32_strerror (-1) );