mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
gpg: New experimental import option "bulk-import"
* g10/options.h (IMPORT_BULK): New. * g10/import.c (parse_import_options): Add "bulk-import". * g10/call-keyboxd.c (in_transaction): New var. (gpg_keyboxd_deinit_session_data): Run a commit if in bulk import mode. (create_new_context): Run a begin transaction if in bulk import mode. -- Initial tests with this option are not very promising. Importing about 3000 real world keys with --use-keyboxd and full logging took: real 33m31.724s user 19m54.265s sys 2m49.662s With bulk-import this saves a mere 12%: real 29m36.542s user 19m3.391s sys 2m46.728s Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
c2b14f5d68
commit
d49a945b12
4 changed files with 44 additions and 4 deletions
|
@ -70,9 +70,13 @@ struct keyboxd_local_s
|
|||
|
||||
/* Flag indicating that a search reset is required. */
|
||||
unsigned int need_search_reset : 1;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/* Flag indicating that for example bulk import is enabled. */
|
||||
static unsigned int in_transaction;
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -81,6 +85,7 @@ void
|
|||
gpg_keyboxd_deinit_session_data (ctrl_t ctrl)
|
||||
{
|
||||
keyboxd_local_t kbl;
|
||||
gpg_error_t err;
|
||||
|
||||
while ((kbl = ctrl->keyboxd_local))
|
||||
{
|
||||
|
@ -91,6 +96,20 @@ gpg_keyboxd_deinit_session_data (ctrl_t ctrl)
|
|||
{
|
||||
kbx_client_data_release (kbl->kcd);
|
||||
kbl->kcd = NULL;
|
||||
if (kbl->ctx && in_transaction)
|
||||
{
|
||||
/* This is our hack to commit the changes done during a
|
||||
* bulk import. If we won't do that the loss of the
|
||||
* connection would trigger a rollback in keyboxd. Note
|
||||
* that transactions are not associated with a
|
||||
* connection. */
|
||||
err = assuan_transact (kbl->ctx, "TRANSACTION commit",
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
if (err)
|
||||
log_error ("error commiting last transaction: %s\n",
|
||||
gpg_strerror (err));
|
||||
in_transaction = 0;
|
||||
}
|
||||
assuan_release (kbl->ctx);
|
||||
kbl->ctx = NULL;
|
||||
}
|
||||
|
@ -139,6 +158,20 @@ create_new_context (ctrl_t ctrl, assuan_context_t *r_ctx)
|
|||
else if (!err && !(err = warn_version_mismatch (ctx, KEYBOXD_NAME)))
|
||||
{
|
||||
/* Place to emit global options. */
|
||||
|
||||
if ((opt.import_options & IMPORT_BULK) && !in_transaction)
|
||||
{
|
||||
err = assuan_transact (ctx, "TRANSACTION begin",
|
||||
NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
if (err)
|
||||
{
|
||||
log_error ("error enabling bulk import option: %s\n",
|
||||
gpg_strerror (err));
|
||||
}
|
||||
else
|
||||
in_transaction = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue