Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 1431749 - gpg2 wastes a whole second waiting for gpg-agent to start
Summary: gpg2 wastes a whole second waiting for gpg-agent to start
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: gnupg2
Version: 24
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Tomas Mraz
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-03-13 17:01 UTC by Miloslav Trmač
Modified: 2017-09-01 17:52 UTC (History)
3 users (show)

Fixed In Version: gnupg2-2.1.20-2.fc26
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-04-27 20:54:39 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Miloslav Trmač 2017-03-13 17:01:32 UTC
Description of problem:
common/asshelp.c:start_new_gpg_agent does (skipping error handling and similar non-important code):
>          err = gnupg_spawn_process_detached (program? program : agent_program,
>                                              argv, NULL);
>              for (i=0; i < SECS_TO_WAIT_FOR_AGENT; i++)
>                {
>                  gnupg_sleep (1);
>                  err = assuan_socket_connect (ctx, sockname, 0, 0);
>                  if (!err)
>                      break;
>                }

As a result, even when the agent is ready to accept a connection very quickly (less than 2 ms in my case), gpg2 is waiting for a _whole second_ before trying to connect at all.

This extremely noticeably slows down automated gpg runs, where each run creates a new $GNUPGHOME and imports a set of keys into it.

Please speed this up, perhaps implementing exponential backoff (1/2/4/8/… ms up to the current 1 s, or so), or perhaps teaching gpg-agent to close a single-purpose pipe after its listen() succeeds, so that gpg-agent can create such a p ipe and block until it is closed = try to connect as soon as possible instead of having to guess how long to wait.

Version-Release number of selected component (if applicable):
gnupg2-2.1.13-2.fc24.x86_64 (observation)
gnupg2-2.1.18-2.fc26.src.rpm (examined source code)


Steps to Reproduce:
1. mkdir t
2. (time GNUPGHOME=$(pwd)/t gpg2 --list-keys)
3. (time GNUPGHOME=$(pwd)/t gpg2 --import < ~/.gnupg/pubring.gpg)
3. (time GNUPGHOME=$(pwd)/t gpg2 --import < ~/.gnupg/pubring.gpg)

Actual results:
2. takes 0.004 seconds (all values real time)
3. autostarts the agent, and takes 1.012 seconds
4. reuses an existing agent, and takes 0.013 seconds

Expected results:
3. takes less than, say, 0.30 seconds

Comment 1 Fedora Update System 2017-04-24 16:01:13 UTC
gnupg2-2.1.20-1.fc26 has been submitted as an update to Fedora 26. https://bodhi.fedoraproject.org/updates/FEDORA-2017-f2b99a5ac7

Comment 2 Fedora Update System 2017-04-25 21:28:55 UTC
gnupg2-2.1.20-1.fc26 has been pushed to the Fedora 26 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-f2b99a5ac7

Comment 3 Fedora Update System 2017-04-26 07:23:43 UTC
gnupg2-2.1.20-2.fc26 has been submitted as an update to Fedora 26. https://bodhi.fedoraproject.org/updates/FEDORA-2017-f2b99a5ac7

Comment 4 Fedora Update System 2017-04-26 21:52:15 UTC
gnupg2-2.1.20-2.fc26 has been pushed to the Fedora 26 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-f2b99a5ac7

Comment 5 Fedora Update System 2017-04-27 20:54:39 UTC
gnupg2-2.1.20-2.fc26 has been pushed to the Fedora 26 stable repository. If problems still persist, please make note of it in this bug report.

Comment 6 Miloslav Trmač 2017-08-31 17:49:38 UTC
Thanks for the fix. Has it been sent upstream?

Comment 7 Tomas Mraz 2017-09-01 07:51:29 UTC
Now it has https://dev.gnupg.org/T3380

Comment 8 Miloslav Trmač 2017-09-01 17:52:02 UTC
Thanks again!


Note You need to log in before you can comment on or make changes to this bug.