[Debtags-commits] [svn] r939 - in debtags-edit/trunk: . src
Enrico Zini
debtags-commits@lists.alioth.debian.org
Sun, 19 Jun 2005 21:32:01 +0000
Author: enrico
Date: Sun Jun 19 21:32:00 2005
New Revision: 939
Modified:
debtags-edit/trunk/README
debtags-edit/trunk/src/DebtagsDocument.cc
debtags-edit/trunk/src/DebtagsDocument.h
Log:
Removed some segfaults due to unprotected thread interactions
Modified: debtags-edit/trunk/README
==============================================================================
--- debtags-edit/trunk/README (original)
+++ debtags-edit/trunk/README Sun Jun 19 21:32:00 2005
@@ -1,5 +1,5 @@
-README for debtags-edit 1.0
-===========================
+README for debtags-edit 1.0.1
+=============================
Functionality
-------------
@@ -17,6 +17,8 @@
debtags-edit has been ported to libdebtags1 1.0.3 and it now uses DebtagsSimple
instead of Debtags::Environment.
+Removed segfaults due to bad thread interaction.
+
Compiling from the subversion repository
----------------------------------------
Modified: debtags-edit/trunk/src/DebtagsDocument.cc
==============================================================================
--- debtags-edit/trunk/src/DebtagsDocument.cc (original)
+++ debtags-edit/trunk/src/DebtagsDocument.cc Sun Jun 19 21:32:00 2005
@@ -44,6 +44,18 @@
regenerateSpecials();
}
+DebtagsDocument::~DebtagsDocument()
+{
+ MutexLock lock(specialsMutex);
+ if (hasSpecials == GENERATING)
+ {
+ specialsGen.interrupt();
+ specialsMutex.unlock();
+ specialsGen.join();
+ specialsMutex.lock();
+ }
+}
+
bool DebtagsDocument::SpecialsGen::advance(int steps) throw ()
{
fprintf(stderr, "SpecialsGen thread: %d step(s)\n", steps);
@@ -85,9 +97,9 @@
{
// Limit the number of packages, to have decent times during debugging
TFLimit<string> limFilter(100, &doc.specials);
- doc.tagDB().output(limFilter);
+ coll.output(limFilter);
} else {
- doc.tagDB().output(doc.specials);
+ coll.output(doc.specials);
}
fprintf(stderr, "SpecialsGen thread: specials fed data\n");
if (_interrupt) return 0;
@@ -123,6 +135,8 @@
hasSpecials = GENERATING;
}
specialsGen.interrupt(false);
+ specialsGen.coll = Tagcoll::ItemGrouper<std::string, Debtags::Tag>();
+ tagDB().output(specialsGen.coll);
specialsGen.start();
}
Modified: debtags-edit/trunk/src/DebtagsDocument.h
==============================================================================
--- debtags-edit/trunk/src/DebtagsDocument.h (original)
+++ debtags-edit/trunk/src/DebtagsDocument.h Sun Jun 19 21:32:00 2005
@@ -32,6 +32,7 @@
//#include <debtags/PackageSet.h>
#include <tagcoll/Patches.h>
#include <tagcoll/InputMerger.h>
+#include <tagcoll/ItemGrouper.h>
#include <debtags/DebtagsTODO.h>
@@ -52,6 +53,7 @@
{
protected:
DebtagsDocument& doc;
+ Tagcoll::ItemGrouper<std::string, Debtags::Tag> coll;
bool _interrupt;
virtual const char* threadTag() { return "SpecialsGen"; }
@@ -64,6 +66,8 @@
void interrupt(bool val = true) throw () { _interrupt = val; }
bool advance(int steps = 1) throw ();
+
+ friend class DebtagsDocument;
};
//HandleMaker<T> _handleMaker;
@@ -88,7 +92,7 @@
public:
DebtagsDocument() throw ();
- virtual ~DebtagsDocument() {}
+ virtual ~DebtagsDocument();
Debtags::PackageDB& packageDB() throw () { return _packageDB; }
const Debtags::PackageDB& packageDB() const throw () { return _packageDB; }