From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 125695 invoked by alias); 7 Nov 2017 18:17:47 -0000 Mailing-List: contact cygwin-apps-help@cygwin.com; run by ezmlm Precedence: bulk Sender: cygwin-apps-owner@cygwin.com List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Mail-Followup-To: cygwin-apps@cygwin.com Received: (qmail 125604 invoked by uid 89); 7 Nov 2017 18:17:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.0 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=Pool X-HELO: rgout02.bt.lon5.cpcloud.co.uk Received: from rgout0202.bt.lon5.cpcloud.co.uk (HELO rgout02.bt.lon5.cpcloud.co.uk) (65.20.0.201) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 07 Nov 2017 18:17:45 +0000 X-OWM-Source-IP: 86.162.230.154 (GB) X-OWM-Env-Sender: jonturney@btinternet.com X-Junkmail-Premium-Raw: score=7/50,refid=2.7.2:2017.11.7.174516:17:7.944,ip=,rules=__HAS_FROM, __TO_MALFORMED_2, __TO_NO_NAME, __HAS_CC_HDR, __CC_NAME, __CC_NAME_DIFF_FROM_ACC, __HAS_MSGID, __SANE_MSGID, __HAS_X_MAILER, __IN_REP_TO, __REFERENCES, __FROM_DOMAIN_IN_ANY_CC1, __NO_HTML_TAG_RAW, BODY_SIZE_3000_3999, __MIME_TEXT_P1, __MIME_TEXT_ONLY, HTML_00_01, HTML_00_10, BODY_SIZE_5000_LESS, IN_REP_TO, MSG_THREAD, __FROM_DOMAIN_IN_RCPT, __CC_REAL_NAMES, MULTIPLE_REAL_RCPTS, LEGITIMATE_SIGNS, NO_URI_FOUND, NO_CTA_URI_FOUND, __MIME_TEXT_P, REFERENCES, NO_URI_HTTPS, BODY_SIZE_7000_LESS Received: from localhost.localdomain (86.162.230.154) by rgout02.bt.lon5.cpcloud.co.uk (9.0.019.13-1) (authenticated as jonturney@btinternet.com) id 59D91D94034C7A3F; Tue, 7 Nov 2017 18:17:45 +0000 From: Jon Turney To: cygwin-apps@cygwin.com Cc: Jon Turney 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 Message-Id: <20171107181703.51016-3-jon.turney@dronecode.org.uk> In-Reply-To: <20171107181703.51016-1-jon.turney@dronecode.org.uk> References: <20171107181703.51016-1-jon.turney@dronecode.org.uk> X-SW-Source: 2017-11/txt/msg00022.txt.bz2 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