Skip to content

Commit

Permalink
fix: SIGBRT when installing two apps
Browse files Browse the repository at this point in the history
ostree_repo_pull() will iterate the thread default main context,
We new a new context before call ostree_repo_pull().

Log:
  • Loading branch information
kamiyadm authored and dengbo11 committed Aug 12, 2024
1 parent 849d16c commit 4d992b2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions libs/linglong/src/linglong/repo/ostree_repo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,9 @@ void OSTreeRepo::pull(service::InstallTask &taskContext,
Q_ASSERT(progress != nullptr);

g_autoptr(GError) gErr = nullptr;

auto threadContext = g_main_context_new();
g_main_context_push_thread_default(threadContext);
auto status = ostree_repo_pull(this->ostreeRepo.get(),
this->cfg.defaultRepo.c_str(),
refs,
Expand All @@ -1269,6 +1272,7 @@ void OSTreeRepo::pull(service::InstallTask &taskContext,
cancellable,
&gErr);
ostree_async_progress_finish(progress);
g_main_context_unref(threadContext);
if (status == FALSE) {
// fallback to old ref
qWarning() << gErr->message;
Expand All @@ -1278,13 +1282,18 @@ void OSTreeRepo::pull(service::InstallTask &taskContext,
char *oldRefs[] = { (char *)refString.data(), nullptr };

g_clear_error(&gErr);

auto threadContext = g_main_context_new();
g_main_context_push_thread_default(threadContext);
status = ostree_repo_pull(this->ostreeRepo.get(),
this->cfg.defaultRepo.c_str(),
oldRefs,
OSTREE_REPO_PULL_FLAGS_MIRROR,
progress,
cancellable,
&gErr);
ostree_async_progress_finish(progress);
g_main_context_unref(threadContext);
if (status == FALSE) {
taskContext.reportError(LINGLONG_ERRV("ostree_repo_pull", gErr));
return;
Expand Down

0 comments on commit 4d992b2

Please sign in to comment.