aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/GpgCoreInit.cpp
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2023-10-19 10:51:20 +0000
committersaturneric <[email protected]>2023-10-19 10:51:20 +0000
commit025c268f91ee1deab17891f00dc8c90c4770224f (patch)
tree3454263c7e5d4545bc5bac624eba17ca71257654 /src/core/GpgCoreInit.cpp
parentfeat: using pool for concurrent executions, not stable yet (diff)
downloadGpgFrontend-025c268f91ee1deab17891f00dc8c90c4770224f.tar.gz
GpgFrontend-025c268f91ee1deab17891f00dc8c90c4770224f.zip
fix: improve the stability of thread system
Diffstat (limited to 'src/core/GpgCoreInit.cpp')
-rw-r--r--src/core/GpgCoreInit.cpp62
1 files changed, 32 insertions, 30 deletions
diff --git a/src/core/GpgCoreInit.cpp b/src/core/GpgCoreInit.cpp
index 0441b7d8..62344287 100644
--- a/src/core/GpgCoreInit.cpp
+++ b/src/core/GpgCoreInit.cpp
@@ -206,36 +206,38 @@ void init_gpgfrontend_core() {
// async init no-ascii channel
Thread::TaskRunnerGetter::GetInstance()
.GetTaskRunner(Thread::TaskRunnerGetter::kTaskRunnerType_GPG)
- ->PostTask(new Thread::Task([=](Thread::DataObjectPtr data_obj) -> int {
- // init non-ascii channel
- auto& ctx = GpgFrontend::GpgContext::CreateInstance(
- GPGFRONTEND_NON_ASCII_CHANNEL,
- [=]() -> std::unique_ptr<ChannelObject> {
- GpgFrontend::GpgContextInitArgs args;
- args.ascii = false;
-
- // set key database path
- if (use_custom_key_database_path &&
- !custom_key_database_path.empty()) {
- args.db_path = custom_key_database_path;
- }
-
- if (use_custom_gnupg_install_path) {
- args.custom_gpgconf = true;
- args.custom_gpgconf_path =
- custom_gnupg_install_fs_path.u8string();
- }
-
- args.offline_mode = forbid_all_gnupg_connection;
- args.auto_import_missing_key = auto_import_missing_key;
- args.use_pinentry = use_pinentry_as_password_input_dialog;
-
- return std::unique_ptr<ChannelObject>(new GpgContext(args));
- });
-
- if (!ctx.good()) SPDLOG_ERROR("no-ascii channel init error");
- return ctx.good() ? 0 : -1;
- }));
+ ->PostTask(new Thread::Task(
+ [=](Thread::DataObjectPtr data_obj) -> int {
+ // init non-ascii channel
+ auto& ctx = GpgFrontend::GpgContext::CreateInstance(
+ GPGFRONTEND_NON_ASCII_CHANNEL,
+ [=]() -> std::unique_ptr<ChannelObject> {
+ GpgFrontend::GpgContextInitArgs args;
+ args.ascii = false;
+
+ // set key database path
+ if (use_custom_key_database_path &&
+ !custom_key_database_path.empty()) {
+ args.db_path = custom_key_database_path;
+ }
+
+ if (use_custom_gnupg_install_path) {
+ args.custom_gpgconf = true;
+ args.custom_gpgconf_path =
+ custom_gnupg_install_fs_path.u8string();
+ }
+
+ args.offline_mode = forbid_all_gnupg_connection;
+ args.auto_import_missing_key = auto_import_missing_key;
+ args.use_pinentry = use_pinentry_as_password_input_dialog;
+
+ return std::unique_ptr<ChannelObject>(new GpgContext(args));
+ });
+
+ if (!ctx.good()) SPDLOG_ERROR("no-ascii channel init error");
+ return ctx.good() ? 0 : -1;
+ },
+ "default_channel_ctx_init"));
// try to restart all components
GpgFrontend::GpgAdvancedOperator::GetInstance().RestartGpgComponents();