From: Jon Turney <jon.turney@dronecode.org.uk>
To: cygwin-apps@cygwin.com
Cc: Jon Turney <jon.turney@dronecode.org.uk>
Subject: [PATCH setup 3/5] Ensure packagedb and underlying solver pool is empty before we read setup.ini
Date: Tue, 07 Nov 2017 18:17:00 -0000 [thread overview]
Message-ID: <20171107181703.51016-3-jon.turney@dronecode.org.uk> (raw)
In-Reply-To: <20171107181703.51016-1-jon.turney@dronecode.org.uk>
We need to make sure the packagedb is empty if we step backwards to here.
v2:
Also clear solver stored in SolverSolution, which holds a pool pointer
---
ini.cc | 3 +++
libsolv.cc | 22 ++++++++++++++++++++++
libsolv.h | 3 +++
package_db.cc | 14 ++++++++++++++
package_db.h | 1 +
5 files changed, 43 insertions(+)
diff --git a/ini.cc b/ini.cc
index 85325c3..9bd72fb 100644
--- a/ini.cc
+++ b/ini.cc
@@ -347,6 +347,9 @@ do_remote_ini (HWND owner)
static bool
do_ini_thread (HINSTANCE h, HWND owner)
{
+ packagedb db;
+ db.init();
+
bool ini_error = true;
if (source == IDC_SOURCE_LOCALDIR)
ini_error = do_local_ini (owner);
diff --git a/libsolv.cc b/libsolv.cc
index 9dd1eeb..29a26a9 100644
--- a/libsolv.cc
+++ b/libsolv.cc
@@ -316,6 +316,12 @@ void debug_callback(Pool *pool, void *data, int type, const char *str)
}
SolverPool::SolverPool()
+{
+ init();
+}
+
+void
+SolverPool::init()
{
/* create a pool */
pool = pool_create();
@@ -333,6 +339,16 @@ SolverPool::SolverPool()
pool_set_installed(pool, installed->repo);
}
+void
+SolverPool::clear()
+{
+ repos.clear();
+ pool_free(pool);
+ pool = NULL;
+
+ init();
+}
+
SolvRepo *
SolverPool::getRepo(const std::string &name, bool test)
{
@@ -583,6 +599,12 @@ SolverPool::use_test_packages(bool use_test_packages)
// ---------------------------------------------------------------------------
SolverSolution::~SolverSolution()
+{
+ clear();
+}
+
+void
+SolverSolution::clear()
{
if (solv)
{
diff --git a/libsolv.h b/libsolv.h
index 65e1610..cddf76f 100644
--- a/libsolv.h
+++ b/libsolv.h
@@ -130,6 +130,7 @@ class SolverPool
{
public:
SolverPool();
+ void clear();
SolvRepo *getRepo(const std::string &name, bool test = false);
// Utility class for passing arguments to addPackage()
@@ -158,6 +159,7 @@ public:
private:
+ void init();
Id makedeps(Repo *repo, PackageDepends *requires);
Pool *pool;
@@ -236,6 +238,7 @@ class SolverSolution
public:
SolverSolution(SolverPool &_pool) : pool(_pool), solv(NULL) {};
~SolverSolution();
+ void clear();
/* Reset package database to correspond to trans */
void trans2db() const;
diff --git a/package_db.cc b/package_db.cc
index 66e7f0a..8fbec44 100644
--- a/package_db.cc
+++ b/package_db.cc
@@ -47,6 +47,20 @@ packagedb::packagedb ()
{
}
+void
+packagedb::init ()
+{
+ installeddbread = 0;
+ installeddbver = 0;
+ packages.clear();
+ sourcePackages.clear();
+ categories.clear();
+ solver.clear();
+ solution.clear();
+ basepkg = packageversion();
+ dependencyOrderedPackages.clear();
+}
+
void
packagedb::read ()
{
diff --git a/package_db.h b/package_db.h
index d7127a6..a26c387 100644
--- a/package_db.h
+++ b/package_db.h
@@ -64,6 +64,7 @@ class packagedb
{
public:
packagedb ();
+ void init();
void read();
void makeBase();
/* 0 on success */
--
2.15.0
next prev parent reply other threads:[~2017-11-07 18:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-01 20:38 [setup topic/libsolv] Crash after incomplete download Ken Brown
2017-11-02 17:22 ` Jon Turney
2017-11-02 19:25 ` Ken Brown
2017-11-07 18:15 ` Jon Turney
2017-11-07 18:17 ` [PATCH setup 1/5] Make do_ini() succeed if found_ini_list is empty Jon Turney
2017-11-07 18:17 ` Jon Turney [this message]
2017-11-07 18:17 ` [PATCH setup 2/5] Simplify LocalDirPage::OnNext() Jon Turney
2017-11-07 18:17 ` [PATCH setup 4/5] Correctly order preparing packagedb for chooser Jon Turney
2017-11-07 18:17 ` [PATCH setup 5/5] More crash avoidance in SolvableVersion member functions Jon Turney
2017-11-07 23:00 ` [setup topic/libsolv] Crash after incomplete download Ken Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171107181703.51016-3-jon.turney@dronecode.org.uk \
--to=jon.turney@dronecode.org.uk \
--cc=cygwin-apps@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).