[Pkg-gnupg-commit] [gnupg2] 02/05: gpg-agent: avoid race in shutdown (Closes: #841143)
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Wed Jan 18 20:17:16 UTC 2017
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch master
in repository gnupg2.
commit e9732256b8a1fc1b09b9901f8fac3bf7765abf94
Author: Daniel Kahn Gillmor <dkg at fifthhorseman.net>
Date: Wed Jan 18 11:54:50 2017 -0500
gpg-agent: avoid race in shutdown (Closes: #841143)
---
...educe-sleep-time-in-the-progress-callback.patch | 2 +-
...gent-Avoid-tight-timer-tick-when-possible.patch | 40 +++++++++++++++++-----
...-scheduled-checks-on-socket-when-inotify-.patch | 4 +--
3 files changed, 34 insertions(+), 12 deletions(-)
diff --git a/debian/patches/0061-agent-Reduce-sleep-time-in-the-progress-callback.patch b/debian/patches/0061-agent-Reduce-sleep-time-in-the-progress-callback.patch
index 337aee4..b7e57c6 100644
--- a/debian/patches/0061-agent-Reduce-sleep-time-in-the-progress-callback.patch
+++ b/debian/patches/0061-agent-Reduce-sleep-time-in-the-progress-callback.patch
@@ -15,7 +15,7 @@ Signed-off-by: Werner Koch <wk at gnupg.org>
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c
-index 6bd0c3b57..f665078ba 100644
+index b11d4985c..bda134a97 100644
--- a/agent/gpg-agent.c
+++ b/agent/gpg-agent.c
@@ -1770,11 +1770,19 @@ agent_libgcrypt_progress_cb (void *data, const char *what, int printchar,
diff --git a/debian/patches/gpg-agent-idling/0003-agent-Avoid-tight-timer-tick-when-possible.patch b/debian/patches/gpg-agent-idling/0003-agent-Avoid-tight-timer-tick-when-possible.patch
index 1732387..d09bdc0 100644
--- a/debian/patches/gpg-agent-idling/0003-agent-Avoid-tight-timer-tick-when-possible.patch
+++ b/debian/patches/gpg-agent-idling/0003-agent-Avoid-tight-timer-tick-when-possible.patch
@@ -6,6 +6,8 @@ Subject: agent: Avoid tight timer tick when possible.
handle_tick() is needed.
(handle_connections): On each cycle of the select loop, adjust whether
we should call handle_tick() or not.
+(start_connection_thread_ssh, do_start_connection_thread): Signal the
+main loop when the child terminates.
* agent/call-scd.c (start_scd): Call interrupt_main_thread_loop() once
the scdaemon thread context has started up.
@@ -14,11 +16,14 @@ the scdaemon thread context has started up.
With this change, an idle gpg-agent that has no scdaemon running only
wakes up once a minute (to check_own_socket).
+Thanks to Ian Jackson and NIIBE Yutaka who helped me improve some of
+the blocking and corner cases.
+
Signed-off-by: Daniel Kahn Gillmor <dkg at fifthhorseman.net>
---
agent/call-scd.c | 4 +++-
- agent/gpg-agent.c | 28 +++++++++++++++++++++++++++-
- 2 files changed, 30 insertions(+), 2 deletions(-)
+ agent/gpg-agent.c | 31 ++++++++++++++++++++++++++++---
+ 2 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/agent/call-scd.c b/agent/call-scd.c
index ba59c1825..1ac0f6ba5 100644
@@ -36,10 +41,10 @@ index ba59c1825..1ac0f6ba5 100644
xfree (abs_homedir);
if (err)
diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c
-index 04a775c9b..92907210d 100644
+index 04a775c9b..d117d03f9 100644
--- a/agent/gpg-agent.c
+++ b/agent/gpg-agent.c
-@@ -2267,6 +2267,29 @@ create_directories (void)
+@@ -2267,6 +2267,26 @@ create_directories (void)
}
@@ -58,9 +63,6 @@ index 04a775c9b..92907210d 100644
+ /* if scdaemon is running, we need to check that it's alive */
+ if (agent_scd_check_running ())
+ return 1;
-+ /* if a shutdown was requested, we wait all connections closing. */
-+ if (shutdown_pending)
-+ return 1;
+ /* otherwise, nothing fine-grained to do. */
+ return 0;
+#endif /*HAVE_W32_SYSTEM*/
@@ -69,7 +71,7 @@ index 04a775c9b..92907210d 100644
/* This is the worker for the ticker. It is called every few seconds
and may only do fast operations. */
-@@ -2325,7 +2348,7 @@ agent_sigusr2_action (void)
+@@ -2325,7 +2345,7 @@ agent_sigusr2_action (void)
#ifndef HAVE_W32_SYSTEM
/* The signal handler for this program. It is expected to be run in
@@ -78,7 +80,27 @@ index 04a775c9b..92907210d 100644
static void
handle_signal (int signo)
{
-@@ -2872,6 +2895,9 @@ handle_connections (gnupg_fd_t listen_fd,
+@@ -2606,7 +2626,8 @@ do_start_connection_thread (ctrl_t ctrl)
+
+ agent_deinit_default_ctrl (ctrl);
+ xfree (ctrl);
+- active_connections--;
++ if (--active_connections == 0)
++ interrupt_main_thread_loop();
+ return NULL;
+ }
+
+@@ -2686,7 +2707,8 @@ start_connection_thread_ssh (void *arg)
+
+ agent_deinit_default_ctrl (ctrl);
+ xfree (ctrl);
+- active_connections--;
++ if (--active_connections == 0)
++ interrupt_main_thread_loop();
+ return NULL;
+ }
+
+@@ -2872,6 +2894,9 @@ handle_connections (gnupg_fd_t listen_fd,
thus a simple assignment is fine to copy the entire set. */
read_fdset = fdset;
diff --git a/debian/patches/gpg-agent-idling/0004-agent-Avoid-scheduled-checks-on-socket-when-inotify-.patch b/debian/patches/gpg-agent-idling/0004-agent-Avoid-scheduled-checks-on-socket-when-inotify-.patch
index a1b902c..ee1ee7c 100644
--- a/debian/patches/gpg-agent-idling/0004-agent-Avoid-scheduled-checks-on-socket-when-inotify-.patch
+++ b/debian/patches/gpg-agent-idling/0004-agent-Avoid-scheduled-checks-on-socket-when-inotify-.patch
@@ -12,10 +12,10 @@ Signed-off-by: Daniel Kahn Gillmor <dkg at fifthhorseman.net>
1 file changed, 2 insertions(+)
diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c
-index 92907210d..6bd0c3b57 100644
+index d117d03f9..b11d4985c 100644
--- a/agent/gpg-agent.c
+++ b/agent/gpg-agent.c
-@@ -2897,6 +2897,8 @@ handle_connections (gnupg_fd_t listen_fd,
+@@ -2896,6 +2896,8 @@ handle_connections (gnupg_fd_t listen_fd,
/* avoid a fine-grained timer if we don't need one: */
timertbl[0].interval.tv_sec = need_tick () ? TIMERTICK_INTERVAL : 0;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git
More information about the Pkg-gnupg-commit
mailing list