Backport PR #887 to fix a crasher (#1795004)

This commit is contained in:
Adam Williamson 2020-02-05 02:35:04 -08:00
parent 38df6c7b43
commit 881203c2cd
2 changed files with 67 additions and 1 deletions

59
887.patch Normal file
View File

@ -0,0 +1,59 @@
From f18d11984a91e85369218b2c2361425c04671997 Mon Sep 17 00:00:00 2001
From: Jaroslav Rohel <jrohel@redhat.com>
Date: Wed, 29 Jan 2020 08:58:17 +0100
Subject: [PATCH] [context] Create new repo instead of reusing old one
Function dnf_repo_check_internal() was reusing a libdnf::Repo objects.
They were detached from libsolv repository and reseted for new usage.
New libdnf::Repo class instantions are created now. The old remain
connected with libsolv repository.
It can solve some PackageKit problems.
eg. https://bugzilla.redhat.com/show_bug.cgi?id=1795004
---
libdnf/dnf-repo.cpp | 29 +++++++----------------------
1 file changed, 7 insertions(+), 22 deletions(-)
diff --git a/libdnf/dnf-repo.cpp b/libdnf/dnf-repo.cpp
index 45f6d0145..4c56fe3a5 100644
--- a/libdnf/dnf-repo.cpp
+++ b/libdnf/dnf-repo.cpp
@@ -1470,31 +1470,16 @@ dnf_repo_check_internal(DnfRepo *repo,
}
}
- /* init */
- repoImpl->detachLibsolvRepo();
- repoImpl->needs_internalizing = false;
- repoImpl->state_main = _HY_NEW;
- repoImpl->state_filelists = _HY_NEW;
- repoImpl->state_presto = _HY_NEW;
- repoImpl->state_updateinfo = _HY_NEW;
- repoImpl->state_other = _HY_NEW;
- repoImpl->filenames_repodata = 0;
- repoImpl->presto_repodata = 0;
- repoImpl->updateinfo_repodata = 0;
- repoImpl->other_repodata = 0;
- repoImpl->load_flags = 0;
- /* the following three elements are needed for repo rewriting */
- repoImpl->main_nsolvables = 0;
- repoImpl->main_nrepodata = 0;
- repoImpl->main_end = 0;
- priv->repo->setUseIncludes(false);
-
- repoImpl->repomdFn = yum_repo->repomd;
- repoImpl->metadataPaths.clear();
+ /* init newRepo */
+ auto newRepo = hy_repo_create(priv->repo->getId().c_str());
+ hy_repo_free(priv->repo);
+ priv->repo = newRepo;
+ auto newRepoImpl = libdnf::repoGetImpl(newRepo);
+ newRepoImpl->repomdFn = yum_repo->repomd;
for (auto *elem = yum_repo->paths; elem; elem = g_slist_next(elem)) {
if (elem->data) {
auto yumrepopath = static_cast<LrYumRepoPath *>(elem->data);
- repoImpl->metadataPaths[yumrepopath->type] = yumrepopath->path;
+ newRepoImpl->metadataPaths[yumrepopath->type] = yumrepopath->path;
}
}
/* ensure we reset the values from the keyfile */

View File

@ -52,11 +52,15 @@
Name: libdnf
Version: %{libdnf_major_version}.%{libdnf_minor_version}.%{libdnf_micro_version}
Release: 2%{?dist}
Release: 3%{?dist}
Summary: Library providing simplified C and Python API to libsolv
License: LGPLv2+
URL: https://github.com/rpm-software-management/libdnf
Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz
# https://github.com/rpm-software-management/libdnf/pull/887
# Fixes a crash sometimes encountered in Cockpit:
# https://bugzilla.redhat.com/show_bug.cgi?id=1795004
Patch0: 887.patch
BuildRequires: cmake
BuildRequires: gcc
@ -293,6 +297,9 @@ popd
%endif
%changelog
* Tue Feb 04 2020 Adam Williamson <adamwill@fedoraproject.org> - 0.43.1-3
- [context] Create new repo instead of reusing old one (RhBug:1795004)
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.43.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild