From 46d185f60397f68830bfdfb99627b29aea5016f1 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Fri, 17 Jul 2020 11:11:45 +0900 Subject: [PATCH] scd: PC/SC: Don't release the context when it's in use. * scd/apdu.c (close_pcsc_reader): Check if it's not in the loop. -- GnuPG-bug-id: 4998 Reported-by: Kevin Locke Signed-off-by: NIIBE Yutaka --- common/init.c | 11 ----------- dirmngr/dirmngr-client.c | 10 ---------- scd/apdu.c | 2 +- 3 files changed, 1 insertion(+), 22 deletions(-) diff --git a/common/init.c b/common/init.c index 073c5cd8a..dbdf40527 100644 --- a/common/init.c +++ b/common/init.c @@ -161,17 +161,6 @@ _init_common_subsystems (gpg_err_source_t errsource, int *argcp, char ***argvp) /* Try to auto set the character set. */ set_native_charset (NULL); -#ifdef HAVE_W32_SYSTEM - /* For W32 we need to initialize the socket layer. This is because - we use recv and send in libassuan as well as at some other - places. */ - { - WSADATA wsadat; - - WSAStartup (0x202, &wsadat); - } -#endif - #ifdef HAVE_W32CE_SYSTEM /* Register the sleep exit function before the estream init so that the sleep will be called after the estream registered atexit diff --git a/dirmngr/dirmngr-client.c b/dirmngr/dirmngr-client.c index 1ea10a8ad..f65a7fcfa 100644 --- a/dirmngr/dirmngr-client.c +++ b/dirmngr/dirmngr-client.c @@ -208,16 +208,6 @@ main (int argc, char **argv ) * init_common_subsystems, but we don't need that here. */ gpgrt_set_fixed_string_mapper (map_static_macro_string); - /* For W32 we need to initialize the socket subsystem. Because we - don't use Pth we need to do this explicit. */ -#ifdef HAVE_W32_SYSTEM - { - WSADATA wsadat; - - WSAStartup (0x202, &wsadat); - } -#endif /*HAVE_W32_SYSTEM*/ - /* Init Assuan. */ assuan_set_assuan_log_prefix (log_get_prefix (NULL)); assuan_set_gpg_err_source (GPG_ERR_SOURCE_DEFAULT); diff --git a/scd/apdu.c b/scd/apdu.c index 46d18b14b..33951a2da 100644 --- a/scd/apdu.c +++ b/scd/apdu.c @@ -813,7 +813,7 @@ static int close_pcsc_reader (int slot) { (void)slot; - if (--pcsc.count == 0) + if (--pcsc.count == 0 && npth_mutex_trylock (&reader_table_lock) == 0) { int i;