1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

dirmngr: Avoid initial delay on the first keyserver access.

* dirmngr/dirmngr.c (dirmngr_never_use_tor_p): New.
* dirmngr/server.c (ensure_keyserver): Don't even test for the Tor
proxy in never-use-tor Mode.

* tools/gpgtar-create.c: Include unistd.h to avoid a warning on
Windows.
--

This delay of 2 or 3 seconds is in particular annoying on Windows.
This is now suppressed, as it should be, if --no-use-tor is used.

The second patch is unrelated
This commit is contained in:
Werner Koch 2022-02-01 16:02:20 +01:00
parent 623a427b0c
commit 57d546674d
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
4 changed files with 13 additions and 3 deletions

View File

@ -620,6 +620,15 @@ dirmngr_use_tor (void)
}
/* This is somewhat similar to dirmngr_use_tor but avoids a trial
* connect and may thus be faster for this special case. */
int
dirmngr_never_use_tor_p (void)
{
return tor_mode == TOR_MODE_NEVER;
}
static void
wrong_args (const char *text)
{

View File

@ -223,6 +223,7 @@ void dirmngr_deinit_default_ctrl (ctrl_t ctrl);
void dirmngr_sighup_action (void);
const char* dirmngr_get_current_socket_name (void);
int dirmngr_use_tor (void);
int dirmngr_never_use_tor_p (void);
/*-- Various housekeeping functions. --*/
void ks_hkp_housekeeping (time_t curtime);

View File

@ -2276,7 +2276,7 @@ ensure_keyserver (ctrl_t ctrl)
{
/* If there is just one onion and one plain keyserver given, we take
only one depending on whether Tor is running or not. */
if (is_tor_running (ctrl))
if (!dirmngr_never_use_tor_p () && is_tor_running (ctrl))
{
ctrl->server_local->keyservers = onion_items;
onion_items = NULL;
@ -2287,7 +2287,7 @@ ensure_keyserver (ctrl_t ctrl)
plain_items = NULL;
}
}
else if (!is_tor_running (ctrl))
else if (dirmngr_never_use_tor_p () || !is_tor_running (ctrl))
{
/* Tor is not running. It does not make sense to add Onion
addresses. */

View File

@ -28,11 +28,11 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <unistd.h>
#ifdef HAVE_W32_SYSTEM
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#else /*!HAVE_W32_SYSTEM*/
# include <unistd.h>
# include <pwd.h>
# include <grp.h>
#endif /*!HAVE_W32_SYSTEM*/