From ed1cd8733d8a3e0710eaa0a746046e4023653616 Mon Sep 17 00:00:00 2001 From: Ben Kibbey Date: Mon, 29 Aug 2016 23:51:02 -0400 Subject: [PATCH] KILL: A second time will cancel a gpgme operation. Sending a second KILL command for the same TID will break out of gpgme_wait() and really terminate the thread. --- src/commands.c | 1 + src/common.h | 1 + src/crypto.c | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/commands.c b/src/commands.c index dfa33e5f..677b081e 100644 --- a/src/commands.c +++ b/src/commands.c @@ -4290,6 +4290,7 @@ kill_command (assuan_context_t ctx, char *line) rc = peer_is_invoker (client); if (!rc) { + thd->cancel++; #ifdef HAVE_PTHREAD_CANCEL rc = pthread_cancel (thd->tid); #else diff --git a/src/common.h b/src/common.h index 5da4a943..bdfd241d 100644 --- a/src/common.h +++ b/src/common.h @@ -85,6 +85,7 @@ struct client_thread_s struct tls_s *tls; char *peeraddr; #endif + int cancel; }; struct client_s diff --git a/src/crypto.c b/src/crypto.c index 33f59f5b..bc87a883 100644 --- a/src/crypto.c +++ b/src/crypto.c @@ -279,8 +279,8 @@ crypto_cancel_gpgme (void *data) update_client_state (client, CLIENT_STATE_DISCON); gpgme_cancel_async (crypto->ctx); - while (!gpgme_wait (crypto->ctx, &rc, 0) && !rc) - log_write1 (_ ("waiting for operation to finish")); + while (!gpgme_wait (crypto->ctx, &rc, 0) && !rc && client->thd->cancel < 2) + log_write1 (_ ("waiting for gpgme operation to finish")); } gpgme_error_t -- 2.11.4.GIT