mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
gpg: Allow generation of more than 4096 keys in one run.
* g10/getkey.c (cache_public_key): Make room in the cache if needed. -- To create the selfsigs, the key generation code makes use of the key cache. However, after 4096 the cache is filled up and then disabled. Thus generating more than 4096 keys in one run was not possible. We now clear the first half the inserted keys every time the cache gets full.
This commit is contained in:
parent
79f08fb069
commit
7d00e52bd5
26
g10/getkey.c
26
g10/getkey.c
@ -128,7 +128,7 @@ void
|
|||||||
cache_public_key (PKT_public_key * pk)
|
cache_public_key (PKT_public_key * pk)
|
||||||
{
|
{
|
||||||
#if MAX_PK_CACHE_ENTRIES
|
#if MAX_PK_CACHE_ENTRIES
|
||||||
pk_cache_entry_t ce;
|
pk_cache_entry_t ce, ce2;
|
||||||
u32 keyid[2];
|
u32 keyid[2];
|
||||||
|
|
||||||
if (pk_cache_disabled)
|
if (pk_cache_disabled)
|
||||||
@ -158,11 +158,25 @@ cache_public_key (PKT_public_key * pk)
|
|||||||
|
|
||||||
if (pk_cache_entries >= MAX_PK_CACHE_ENTRIES)
|
if (pk_cache_entries >= MAX_PK_CACHE_ENTRIES)
|
||||||
{
|
{
|
||||||
/* fixme: Use another algorithm to free some cache slots. */
|
int n;
|
||||||
pk_cache_disabled = 1;
|
|
||||||
if (opt.verbose > 1)
|
/* Remove the last 50% of the entries. */
|
||||||
log_info (_("too many entries in pk cache - disabled\n"));
|
for (ce = pk_cache, n = 0; ce && n < pk_cache_entries/2; n++)
|
||||||
return;
|
ce = ce->next;
|
||||||
|
if (ce != pk_cache && ce->next)
|
||||||
|
{
|
||||||
|
ce2 = ce->next;
|
||||||
|
ce->next = NULL;
|
||||||
|
ce = ce2;
|
||||||
|
for (; ce; ce = ce2)
|
||||||
|
{
|
||||||
|
ce2 = ce->next;
|
||||||
|
free_public_key (ce->pk);
|
||||||
|
xfree (ce);
|
||||||
|
pk_cache_entries--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert (pk_cache_entries < MAX_PK_CACHE_ENTRIES);
|
||||||
}
|
}
|
||||||
pk_cache_entries++;
|
pk_cache_entries++;
|
||||||
ce = xmalloc (sizeof *ce);
|
ce = xmalloc (sizeof *ce);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user