aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2020-09-10 10:14:02 +0000
committerWerner Koch <[email protected]>2020-09-10 10:14:02 +0000
commit6fcc263c182fc49d9ba2d1bd7649b4af1e9f3e3a (patch)
tree5e00f9750f4a451dc5b339134497f1c92880988f
parentkeyboxd: Add options --openpgp and --x509 to SEARCH. (diff)
downloadgnupg-6fcc263c182fc49d9ba2d1bd7649b4af1e9f3e3a.tar.gz
gnupg-6fcc263c182fc49d9ba2d1bd7649b4af1e9f3e3a.zip
keyboxd: Use D-lines instead of a separate thread.
* kbx/kbx-client-util.c (kbx_client_data_new): Add arg 'dlines'. * g10/call-keyboxd.c (open_context): Set DLINES to true. * sm/keydb.c (open_context): Ditto. -- This allows to compile time switch between the D-line and the fd-passing data communication between gpg/gpgsm and keyboxd. A quick test with about 3000 OpenPGP keys showed that D-lines are only 10% slower than the fd-passing based implementation. Given that the thread adds extra complexity we go for now with the D-line approach. Signed-off-by: Werner Koch <[email protected]>
-rw-r--r--g10/call-keyboxd.c2
-rw-r--r--kbx/kbx-client-util.c12
-rw-r--r--kbx/kbx-client-util.h2
-rw-r--r--sm/keydb.c2
4 files changed, 12 insertions, 6 deletions
diff --git a/g10/call-keyboxd.c b/g10/call-keyboxd.c
index e0ee26e6b..e75b786a0 100644
--- a/g10/call-keyboxd.c
+++ b/g10/call-keyboxd.c
@@ -190,7 +190,7 @@ open_context (ctrl_t ctrl, keyboxd_local_t *r_kbl)
return err;
}
- err = kbx_client_data_new (&kbl->kcd, kbl->ctx);
+ err = kbx_client_data_new (&kbl->kcd, kbl->ctx, 1);
if (err)
{
assuan_release (kbl->ctx);
diff --git a/kbx/kbx-client-util.c b/kbx/kbx-client-util.c
index ba356b3c5..910050372 100644
--- a/kbx/kbx-client-util.c
+++ b/kbx/kbx-client-util.c
@@ -270,10 +270,12 @@ datastream_thread (void *arg)
/* Create a new keyboxd client data object and return it at R_KCD.
- * CTX is the assuan context to be used for connecting the
- * keyboxd. */
+ * CTX is the assuan context to be used for connecting the keyboxd.
+ * If dlines is set, communication is done without fd passing via
+ * D-lines. */
gpg_error_t
-kbx_client_data_new (kbx_client_data_t *r_kcd, assuan_context_t ctx)
+kbx_client_data_new (kbx_client_data_t *r_kcd, assuan_context_t ctx,
+ int dlines)
{
kbx_client_data_t kcd;
int rc;
@@ -285,6 +287,9 @@ kbx_client_data_new (kbx_client_data_t *r_kcd, assuan_context_t ctx)
kcd->ctx = ctx;
+ if (dlines)
+ goto leave;
+
rc = npth_mutex_init (&kcd->mutex, NULL);
if (rc)
{
@@ -312,6 +317,7 @@ kbx_client_data_new (kbx_client_data_t *r_kcd, assuan_context_t ctx)
return err;
}
+ leave:
*r_kcd = kcd;
return 0;
}
diff --git a/kbx/kbx-client-util.h b/kbx/kbx-client-util.h
index db6cb9475..1cc68b5a0 100644
--- a/kbx/kbx-client-util.h
+++ b/kbx/kbx-client-util.h
@@ -26,7 +26,7 @@ struct kbx_client_data_s;
typedef struct kbx_client_data_s *kbx_client_data_t;
gpg_error_t kbx_client_data_new (kbx_client_data_t *r_kcd,
- assuan_context_t ctx);
+ assuan_context_t ctx, int dlines);
void kbx_client_data_release (kbx_client_data_t kcd);
gpg_error_t kbx_client_data_cmd (kbx_client_data_t kcd, const char *command,
gpg_error_t (*status_cb)(void *opaque,
diff --git a/sm/keydb.c b/sm/keydb.c
index ca32162d1..d7525bd76 100644
--- a/sm/keydb.c
+++ b/sm/keydb.c
@@ -570,7 +570,7 @@ open_context (ctrl_t ctrl, keydb_local_t *r_kbl)
return err;
}
- err = kbx_client_data_new (&kbl->kcd, kbl->ctx);
+ err = kbx_client_data_new (&kbl->kcd, kbl->ctx, 1);
if (err)
{
assuan_release (kbl->ctx);