diff options
author | NIIBE Yutaka <[email protected]> | 2023-06-07 06:26:34 +0000 |
---|---|---|
committer | NIIBE Yutaka <[email protected]> | 2023-06-07 06:26:34 +0000 |
commit | f5656ff363a00c7649224d827b92c3e6031b6b77 (patch) | |
tree | 0106ad642b8f1f1839987de17952a983b1ebabce /g10/call-keyboxd.c | |
parent | common: Add test case for IPC with spawned process. (diff) | |
download | gnupg-f5656ff363a00c7649224d827b92c3e6031b6b77.tar.gz gnupg-f5656ff363a00c7649224d827b92c3e6031b6b77.zip |
kbx: Fix datastream_thread and use the data pipe.
* g10/call-keyboxd.c (gpg_keyboxd_deinit_session_data): Release
the assuan connection before kbx_client_data_release.
(open_context): Enable use of the data pipe.
* sm/keydb.c (gpgsm_keydb_deinit_session_data): Release the
assuan connection before kbx_client_data_release.
(open_context): Enable use of the data pipe.
* kbx/kbx-client-util.c (struct kbx_client_data_s): Add THD field.
(prepare_data_pipe): Close the pipe output end as it's been sent
already. Remember the KCD->THD, so that it can be joined later.
(datastream_thread): Finish when reading no data from the pipe.
(kbx_client_data_release): Join the thread. Then, we can safely
call es_fclose on the FP.
--
GnuPG-bug-id: 6512
Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'g10/call-keyboxd.c')
-rw-r--r-- | g10/call-keyboxd.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/g10/call-keyboxd.c b/g10/call-keyboxd.c index 7f4d5f493..dc3d30a93 100644 --- a/g10/call-keyboxd.c +++ b/g10/call-keyboxd.c @@ -94,8 +94,6 @@ gpg_keyboxd_deinit_session_data (ctrl_t ctrl) log_error ("oops: trying to cleanup an active keyboxd context\n"); else { - 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 @@ -112,6 +110,15 @@ gpg_keyboxd_deinit_session_data (ctrl_t ctrl) } assuan_release (kbl->ctx); kbl->ctx = NULL; + /* + * Since there may be pipe output FD sent to the server (so + * that it can receive data through the pipe), we should + * release the assuan connection before releasing KBL->KCD. + * This way, the data receiving thread can finish cleanly, + * and we can join the thread. + */ + kbx_client_data_release (kbl->kcd); + kbl->kcd = NULL; } xfree (kbl); } @@ -223,7 +230,7 @@ open_context (ctrl_t ctrl, keyboxd_local_t *r_kbl) return err; } - err = kbx_client_data_new (&kbl->kcd, kbl->ctx, 1); + err = kbx_client_data_new (&kbl->kcd, kbl->ctx, 0); if (err) { assuan_release (kbl->ctx); |