better handle aspell errors: dont exit from monitor on aux db creation failure, and dont retry forever

This commit is contained in:
dockes 2007-05-21 09:00:29 +00:00
parent 134edf9c45
commit 3db31b4079
2 changed files with 22 additions and 7 deletions

View File

@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: indexer.cpp,v 1.53 2007-02-08 17:05:12 dockes Exp $ (C) 2004 J.F.Dockes";
static char rcsid[] = "@(#$Id: indexer.cpp,v 1.54 2007-05-21 09:00:28 dockes Exp $ (C) 2004 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -201,8 +201,15 @@ bool DbIndexer::createAspellDict()
{
LOGDEB2(("DbIndexer::createAspellDict()\n"));
#ifdef RCL_USE_ASPELL
bool noaspell = false;
m_config->getConfParam("noaspell", &noaspell);
// For the benefit of the real-time indexer, we only initialize
// noaspell from the configuration once. It can then be set to
// true if dictionary generation fails, which avoids retrying
// it forever.
static int noaspell = -12345;
if (noaspell == -12345) {
noaspell = false;
m_config->getConfParam("noaspell", &noaspell);
}
if (noaspell)
return true;
@ -213,18 +220,21 @@ bool DbIndexer::createAspellDict()
if (!aspell.init(reason)) {
LOGERR(("DbIndexer::createAspellDict: aspell init failed: %s\n",
reason.c_str()));
noaspell = true;
return false;
}
LOGDEB(("DbIndexer::createAspellDict: creating dictionary\n"));
if (!aspell.buildDict(m_db, reason)) {
LOGERR(("DbIndexer::createAspellDict: aspell buildDict failed: %s\n",
reason.c_str()));
noaspell = true;
return false;
}
// The close would be done in our destructor, but we want status here
if (!m_db.close()) {
LOGERR(("DbIndexer::indexfiles: error closing database in %s\n",
m_dbdir.c_str()));
noaspell = true;
return false;
}
#endif

View File

@ -2,7 +2,7 @@
#ifdef RCL_MONITOR
#ifndef lint
static char rcsid[] = "@(#$Id: rclmonprc.cpp,v 1.10 2006-12-24 07:40:26 dockes Exp $ (C) 2006 J.F.Dockes";
static char rcsid[] = "@(#$Id: rclmonprc.cpp,v 1.11 2007-05-21 09:00:29 dockes Exp $ (C) 2006 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@ -340,11 +340,16 @@ bool startMonitor(RclConfig *conf, int opts)
}
// Recreate the auxiliary dbs every hour.
if (time(0) - lastauxtime > 60 *60) {
const int auxinterval = 60 *60;
if (didsomething && time(0) - lastauxtime > auxinterval) {
lastauxtime = time(0);
didsomething = false;
if (!createAuxDbs(conf))
break;
if (!createAuxDbs(conf)) {
// We used to bail out on error here. Not anymore,
// because this is most of the time due to a failure
// of aspell dictionary generation, which is not
// critical.
}
}
// Lock queue before waiting again