From e636480622fc14dcadc60c48628e63646f74444c Mon Sep 17 00:00:00 2001 From: dockes Date: Sun, 15 Nov 2009 16:41:05 +0000 Subject: [PATCH] catch cancel exceptions cast by internfile() --- src/index/beaglequeue.cpp | 26 +++++++++++++++++++++++--- src/index/fsindexer.cpp | 8 +++++++- src/utils/circache.cpp | 4 ++-- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/index/beaglequeue.cpp b/src/index/beaglequeue.cpp index b48c18c9..60e0adbc 100644 --- a/src/index/beaglequeue.cpp +++ b/src/index/beaglequeue.cpp @@ -36,6 +36,7 @@ static char rcsid[] = "@(#$Id: $ (C) 2005 J.F.Dockes"; #include "readfile.h" #include "conftree.h" #include "transcode.h" +#include "cancelcheck.h" #include #include @@ -250,6 +251,8 @@ bool BeagleQueueIndexer::indexFromCache(const string& udi) if (!m_db) return false; + CancelCheck::instance().checkCancel(); + Rcl::Doc dotdoc; string data; string hittype; @@ -278,7 +281,13 @@ bool BeagleQueueIndexer::indexFromCache(const string& udi) FileInterner::FIF_doUseInputMimetype, dotdoc.mimetype); string ipath; - FileInterner::Status fis = interner.internfile(doc, ipath); + FileInterner::Status fis; + try { + fis = interner.internfile(doc, ipath); + } catch (CancelExcept) { + LOGERR(("BeagleQueueIndexer: interrupted\n")); + return false; + } if (fis != FileInterner::FIDone) { LOGERR(("BeagleQueueIndexer: bad status from internfile\n")); return false; @@ -324,7 +333,12 @@ bool BeagleQueueIndexer::index() for (vector::reverse_iterator it = alludis.rbegin(); it != alludis.rend(); it++) { if (m_db->needUpdate(*it, "")) { - indexFromCache(*it); + try { + indexFromCache(*it); + } catch (CancelExcept) { + LOGERR(("BeagleQueueIndexer: interrupted\n")); + return false; + } } } } @@ -455,7 +469,13 @@ BeagleQueueIndexer::processone(const string &path, FileInterner::FIF_doUseInputMimetype, &dotdoc.mimetype); string ipath; - FileInterner::Status fis = interner.internfile(doc, ipath); + FileInterner::Status fis; + try { + fis = interner.internfile(doc, ipath); + } catch (CancelExcept) { + LOGERR(("BeagleQueueIndexer: interrupted\n")); + goto out; + } if (fis != FileInterner::FIDone) { LOGERR(("BeagleQueueIndexer: bad status from internfile\n")); goto out; diff --git a/src/index/fsindexer.cpp b/src/index/fsindexer.cpp index 9091e6d0..349e5d91 100644 --- a/src/index/fsindexer.cpp +++ b/src/index/fsindexer.cpp @@ -48,6 +48,7 @@ static char rcsid[] = "@(#$Id: $ (C) 2009 J.F.Dockes"; #include "smallut.h" #include "wipedir.h" #include "fileudi.h" +#include "cancelcheck.h" // When using extended attributes, we have to use the ctime. // This is quite an expensive price to pay... @@ -418,7 +419,12 @@ FsIndexer::processone(const std::string &fn, const struct stat *stp, while (fis == FileInterner::FIAgain) { doc.erase(); string ipath; - fis = interner.internfile(doc, ipath); + try { + fis = interner.internfile(doc, ipath); + } catch (CancelExcept) { + LOGERR(("fsIndexer::processone: interrupted\n")); + return FsTreeWalker::FtwStop; + } // Index at least the file name even if there was an error. // We'll change the signature to ensure that the indexing will diff --git a/src/utils/circache.cpp b/src/utils/circache.cpp index 8dc8c20b..f2d52434 100644 --- a/src/utils/circache.cpp +++ b/src/utils/circache.cpp @@ -471,8 +471,8 @@ public: virtual status takeone(off_t offs, const string& udi, unsigned int dicsize, unsigned int datasize, unsigned int padsize) { - cerr << "offs " << offs << " udi [" << udi << "] dicsize " << dicsize - << " datasize " << datasize << " padsize " << padsize << endl; +// cerr << "offs " << offs << " udi [" << udi << "] dicsize " << dicsize +// << " datasize " << datasize << " padsize " << padsize << endl; if (!m_udi.compare(udi)) { m_instance++; m_offs = offs;