catch cancel exceptions cast by internfile()

This commit is contained in:
dockes 2009-11-15 16:41:05 +00:00
parent 7c245fe986
commit e636480622
3 changed files with 32 additions and 6 deletions

View File

@ -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 <vector>
#include <fstream>
@ -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<string>::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;

View File

@ -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

View File

@ -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;