logging now uses c++ streams
This commit is contained in:
+27
-31
@@ -24,7 +24,7 @@
|
||||
#include "cstr.h"
|
||||
#include "pathut.h"
|
||||
#include "rclutil.h"
|
||||
#include "debuglog.h"
|
||||
#include "log.h"
|
||||
#include "fstreewalk.h"
|
||||
#include "beaglequeue.h"
|
||||
#include "beaglequeuecache.h"
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
m_input.getline(cline, LL-1);
|
||||
if (!m_input.good()) {
|
||||
if (m_input.bad()) {
|
||||
LOGERR(("beagleDotFileRead: input.bad()\n"));
|
||||
LOGERR("beagleDotFileRead: input.bad()\n" );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
ll--;
|
||||
}
|
||||
line.assign(cline, ll);
|
||||
LOGDEB2(("BeagleDotFile:readLine: [%s]\n", line.c_str()));
|
||||
LOGDEB2("BeagleDotFile:readLine: [" << (line) << "]\n" );
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
|
||||
m_input.open(m_fn.c_str(), ios::in);
|
||||
if (!m_input.good()) {
|
||||
LOGERR(("BeagleDotFile: open failed for [%s]\n", m_fn.c_str()));
|
||||
LOGERR("BeagleDotFile: open failed for [" << (m_fn) << "]\n" );
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ BeagleQueueIndexer::BeagleQueueIndexer(RclConfig *cnf, Rcl::Db *db,
|
||||
|
||||
BeagleQueueIndexer::~BeagleQueueIndexer()
|
||||
{
|
||||
LOGDEB(("BeagleQueueIndexer::~\n"));
|
||||
LOGDEB("BeagleQueueIndexer::~\n" );
|
||||
deleteZ(m_cache);
|
||||
}
|
||||
|
||||
@@ -202,12 +202,12 @@ bool BeagleQueueIndexer::indexFromCache(const string& udi)
|
||||
string hittype;
|
||||
|
||||
if (!m_cache || !m_cache->getFromCache(udi, dotdoc, data, &hittype)) {
|
||||
LOGERR(("BeagleQueueIndexer::indexFromCache: cache failed\n"));
|
||||
LOGERR("BeagleQueueIndexer::indexFromCache: cache failed\n" );
|
||||
return false;
|
||||
}
|
||||
|
||||
if (hittype.empty()) {
|
||||
LOGERR(("BeagleIndexer::index: cc entry has no hit type\n"));
|
||||
LOGERR("BeagleIndexer::index: cc entry has no hit type\n" );
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -224,11 +224,11 @@ bool BeagleQueueIndexer::indexFromCache(const string& udi)
|
||||
try {
|
||||
fis = interner.internfile(doc);
|
||||
} catch (CancelExcept) {
|
||||
LOGERR(("BeagleQueueIndexer: interrupted\n"));
|
||||
LOGERR("BeagleQueueIndexer: interrupted\n" );
|
||||
return false;
|
||||
}
|
||||
if (fis != FileInterner::FIDone) {
|
||||
LOGERR(("BeagleQueueIndexer: bad status from internfile\n"));
|
||||
LOGERR("BeagleQueueIndexer: bad status from internfile\n" );
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -257,15 +257,14 @@ bool BeagleQueueIndexer::index()
|
||||
{
|
||||
if (!m_db)
|
||||
return false;
|
||||
LOGDEB(("BeagleQueueIndexer::processqueue: [%s]\n", m_queuedir.c_str()));
|
||||
LOGDEB("BeagleQueueIndexer::processqueue: [" << (m_queuedir) << "]\n" );
|
||||
m_config->setKeyDir(m_queuedir);
|
||||
if (!path_makepath(m_queuedir, 0700)) {
|
||||
LOGERR(("BeagleQueueIndexer:: can't create queuedir [%s] errno %d\n",
|
||||
m_queuedir.c_str(), errno));
|
||||
LOGERR("BeagleQueueIndexer:: can't create queuedir [" << (m_queuedir) << "] errno " << (errno) << "\n" );
|
||||
return false;
|
||||
}
|
||||
if (!m_cache || !m_cache->cc()) {
|
||||
LOGERR(("BeagleQueueIndexer: cache initialization failed\n"));
|
||||
LOGERR("BeagleQueueIndexer: cache initialization failed\n" );
|
||||
return false;
|
||||
}
|
||||
CirCache *cc = m_cache->cc();
|
||||
@@ -283,7 +282,7 @@ bool BeagleQueueIndexer::index()
|
||||
do {
|
||||
string udi;
|
||||
if (!cc->getCurrentUdi(udi)) {
|
||||
LOGERR(("BeagleQueueIndexer:: cache file damaged\n"));
|
||||
LOGERR("BeagleQueueIndexer:: cache file damaged\n" );
|
||||
break;
|
||||
}
|
||||
if (udi.empty())
|
||||
@@ -296,7 +295,7 @@ bool BeagleQueueIndexer::index()
|
||||
indexFromCache(udi);
|
||||
updstatus(udi);
|
||||
} catch (CancelExcept) {
|
||||
LOGERR(("BeagleQueueIndexer: interrupted\n"));
|
||||
LOGERR("BeagleQueueIndexer: interrupted\n" );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -308,17 +307,17 @@ bool BeagleQueueIndexer::index()
|
||||
FsTreeWalker walker(FsTreeWalker::FtwNoRecurse);
|
||||
walker.addSkippedName(".*");
|
||||
FsTreeWalker::Status status = walker.walk(m_queuedir, *this);
|
||||
LOGDEB(("BeagleQueueIndexer::processqueue: done: status %d\n", status));
|
||||
LOGDEB("BeagleQueueIndexer::processqueue: done: status " << (status) << "\n" );
|
||||
return true;
|
||||
}
|
||||
|
||||
// Index a list of files (sent by the real time monitor)
|
||||
bool BeagleQueueIndexer::indexFiles(list<string>& files)
|
||||
{
|
||||
LOGDEB(("BeagleQueueIndexer::indexFiles\n"));
|
||||
LOGDEB("BeagleQueueIndexer::indexFiles\n" );
|
||||
|
||||
if (!m_db) {
|
||||
LOGERR(("BeagleQueueIndexer::indexfiles no db??\n"));
|
||||
LOGERR("BeagleQueueIndexer::indexfiles no db??\n" );
|
||||
return false;
|
||||
}
|
||||
for (list<string>::iterator it = files.begin(); it != files.end();) {
|
||||
@@ -327,8 +326,7 @@ bool BeagleQueueIndexer::indexFiles(list<string>& files)
|
||||
}
|
||||
string father = path_getfather(*it);
|
||||
if (father.compare(m_queuedir)) {
|
||||
LOGDEB(("BeagleQueueIndexer::indexfiles: skipping [%s] (nq)\n",
|
||||
it->c_str()));
|
||||
LOGDEB("BeagleQueueIndexer::indexfiles: skipping [" << *it << "] (nq)\n" );
|
||||
it++; continue;
|
||||
}
|
||||
// Pb: we are often called with the dot file, before the
|
||||
@@ -344,13 +342,11 @@ bool BeagleQueueIndexer::indexFiles(list<string>& files)
|
||||
}
|
||||
struct stat st;
|
||||
if (path_fileprops(*it, &st) != 0) {
|
||||
LOGERR(("BeagleQueueIndexer::indexfiles: cant stat [%s]\n",
|
||||
it->c_str()));
|
||||
LOGERR("BeagleQueueIndexer::indexfiles: cant stat [" << *it << "]\n" );
|
||||
it++; continue;
|
||||
}
|
||||
if (!S_ISREG(st.st_mode)) {
|
||||
LOGDEB(("BeagleQueueIndexer::indexfiles: skipping [%s] (nr)\n",
|
||||
it->c_str()));
|
||||
LOGDEB("BeagleQueueIndexer::indexfiles: skipping [" << *it << "] (nr)\n" );
|
||||
it++; continue;
|
||||
}
|
||||
|
||||
@@ -378,7 +374,7 @@ BeagleQueueIndexer::processone(const string &path,
|
||||
|
||||
string dotpath = path_cat(path_getfather(path),
|
||||
string(".") + path_getsimple(path));
|
||||
LOGDEB(("BeagleQueueIndexer: prc1: [%s]\n", path.c_str()));
|
||||
LOGDEB("BeagleQueueIndexer: prc1: [" << (path) << "]\n" );
|
||||
|
||||
BeagleDotFile dotfile(m_config, dotpath);
|
||||
Rcl::Doc dotdoc;
|
||||
@@ -392,7 +388,7 @@ BeagleQueueIndexer::processone(const string &path,
|
||||
udipath = path_cat(dotdoc.meta[Rcl::Doc::keybght], url_gpath(dotdoc.url));
|
||||
make_udi(udipath, cstr_null, udi);
|
||||
|
||||
LOGDEB(("BeagleQueueIndexer: prc1: udi [%s]\n", udi.c_str()));
|
||||
LOGDEB("BeagleQueueIndexer: prc1: udi [" << (udi) << "]\n" );
|
||||
char ascdate[30];
|
||||
sprintf(ascdate, "%ld", long(stp->st_mtime));
|
||||
|
||||
@@ -424,11 +420,11 @@ BeagleQueueIndexer::processone(const string &path,
|
||||
try {
|
||||
fis = interner.internfile(doc);
|
||||
} catch (CancelExcept) {
|
||||
LOGERR(("BeagleQueueIndexer: interrupted\n"));
|
||||
LOGERR("BeagleQueueIndexer: interrupted\n" );
|
||||
goto out;
|
||||
}
|
||||
if (fis != FileInterner::FIDone && fis != FileInterner::FIAgain) {
|
||||
LOGERR(("BeagleQueueIndexer: bad status from internfile\n"));
|
||||
LOGERR("BeagleQueueIndexer: bad status from internfile\n" );
|
||||
// TOBEDONE: internfile can return FIAgain here if it is
|
||||
// paging a big text file, we should loop. Means we're
|
||||
// only indexing the first page for text/plain files
|
||||
@@ -461,12 +457,11 @@ BeagleQueueIndexer::processone(const string &path,
|
||||
string fdata;
|
||||
file_to_string(path, fdata);
|
||||
if (!m_cache || !m_cache->cc()) {
|
||||
LOGERR(("BeagleQueueIndexer: cache initialization failed\n"));
|
||||
LOGERR("BeagleQueueIndexer: cache initialization failed\n" );
|
||||
goto out;
|
||||
}
|
||||
if (!m_cache->cc()->put(udi, &dotfile.m_fields, fdata, 0)) {
|
||||
LOGERR(("BeagleQueueIndexer::prc1: cache_put failed; %s\n",
|
||||
m_cache->cc()->getReason().c_str()));
|
||||
LOGERR("BeagleQueueIndexer::prc1: cache_put failed; " << (m_cache->cc()->getReason()) << "\n" );
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
@@ -479,3 +474,4 @@ out:
|
||||
}
|
||||
return FsTreeWalker::FtwOk;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,11 +16,10 @@
|
||||
*/
|
||||
#include "autoconfig.h"
|
||||
|
||||
#include "debuglog.h"
|
||||
#include "rcldoc.h"
|
||||
#include "fetcher.h"
|
||||
#include "bglfetcher.h"
|
||||
#include "debuglog.h"
|
||||
#include "log.h"
|
||||
#include "ptmutex.h"
|
||||
#include "beaglequeuecache.h"
|
||||
|
||||
@@ -32,7 +31,7 @@ bool BGLDocFetcher::fetch(RclConfig* cnf, const Rcl::Doc& idoc, RawDoc& out)
|
||||
{
|
||||
string udi;
|
||||
if (!idoc.getmeta(Rcl::Doc::keyudi, &udi) || udi.empty()) {
|
||||
LOGERR(("BGLDocFetcher:: no udi in idoc\n"));
|
||||
LOGERR("BGLDocFetcher:: no udi in idoc\n" );
|
||||
return false;
|
||||
}
|
||||
Rcl::Doc dotdoc;
|
||||
@@ -43,13 +42,12 @@ bool BGLDocFetcher::fetch(RclConfig* cnf, const Rcl::Doc& idoc, RawDoc& out)
|
||||
// deleted when the program exits.
|
||||
static BeagleQueueCache o_beagler(cnf);
|
||||
if (!o_beagler.getFromCache(udi, dotdoc, out.data)) {
|
||||
LOGINFO(("BGLDocFetcher::fetch: failed for [%s]\n", udi.c_str()));
|
||||
LOGINFO("BGLDocFetcher::fetch: failed for [" << (udi) << "]\n" );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (dotdoc.mimetype.compare(idoc.mimetype)) {
|
||||
LOGINFO(("BGLDocFetcher:: udi [%s], mimetp mismatch: in: [%s], bgl "
|
||||
"[%s]\n", idoc.mimetype.c_str(), dotdoc.mimetype.c_str()));
|
||||
LOGINFO("BGLDocFetcher:: udi [" << (udi) << "], mimetp mismatch: in: [" << (idoc.mimetype) << "], bgl [" << (dotdoc.mimetype) << "]\n" );
|
||||
}
|
||||
out.kind = RawDoc::RDK_DATA;
|
||||
return true;
|
||||
@@ -62,3 +60,4 @@ bool BGLDocFetcher::makesig(RclConfig* cnf, const Rcl::Doc& idoc, string& sig)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
#include "rclconfig.h"
|
||||
#include "execmd.h"
|
||||
#include "debuglog.h"
|
||||
#include "log.h"
|
||||
#include "checkretryfailed.h"
|
||||
|
||||
using namespace std;
|
||||
@@ -34,8 +34,7 @@ bool checkRetryFailed(RclConfig *conf, bool record)
|
||||
string cmd;
|
||||
|
||||
if (!conf->getConfParam("checkneedretryindexscript", cmd)) {
|
||||
LOGDEB(("checkRetryFailed: 'checkneedretryindexscript' "
|
||||
"not set in config\n"));
|
||||
LOGDEB("checkRetryFailed: 'checkneedretryindexscript' not set in config\n" );
|
||||
// We could toss a dice ? Say no retry in this case.
|
||||
return false;
|
||||
}
|
||||
@@ -56,3 +55,4 @@ bool checkRetryFailed(RclConfig *conf, bool record)
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
+11
-16
@@ -22,7 +22,7 @@
|
||||
|
||||
#include "exefetcher.h"
|
||||
|
||||
#include "debuglog.h"
|
||||
#include "log.h"
|
||||
#include "pathut.h"
|
||||
#include "rclconfig.h"
|
||||
#include "execmd.h"
|
||||
@@ -47,12 +47,10 @@ public:
|
||||
args.push_back(idoc.ipath);
|
||||
int status = ecmd.doexec1(args, 0, &out);
|
||||
if (status == 0) {
|
||||
LOGDEB(("EXEDocFetcher::Internal: got [%s]\n", out.c_str()));
|
||||
LOGDEB("EXEDocFetcher::Internal: got [" << (out) << "]\n" );
|
||||
return true;
|
||||
} else {
|
||||
LOGERR(("EXEDOcFetcher::fetch: %s: %s failed for %s %s %s 0x%u\n",
|
||||
bckid.c_str(), stringsToString(cmd).c_str(), udi.c_str(),
|
||||
idoc.url.c_str(), idoc.ipath.c_str()));
|
||||
LOGERR("EXEDOcFetcher::fetch: " << (bckid) << ": " << (stringsToString(cmd)) << " failed for " << (udi) << " " << (idoc.url) << " " << (idoc.ipath) << "\n" );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -61,8 +59,7 @@ public:
|
||||
EXEDocFetcher::EXEDocFetcher(const EXEDocFetcher::Internal& _m)
|
||||
{
|
||||
m = new Internal(_m);
|
||||
LOGDEB(("EXEDocFetcher::EXEDocFetcher: fetch is %s\n",
|
||||
stringsToString(m->sfetch).c_str()));
|
||||
LOGDEB("EXEDocFetcher::EXEDocFetcher: fetch is " << (stringsToString(m->sfetch)) << "\n" );
|
||||
}
|
||||
|
||||
bool EXEDocFetcher::fetch(RclConfig* cnf, const Rcl::Doc& idoc, RawDoc& out)
|
||||
@@ -85,13 +82,12 @@ EXEDocFetcher *exeDocFetcherMake(RclConfig *config, const string& bckid)
|
||||
static ConfSimple *bconf;
|
||||
if (!bconf) {
|
||||
string bconfname = path_cat(config->getConfDir(), "backends");
|
||||
LOGDEB(("exeDocFetcherMake: using config in %s\n", bconfname.c_str()));
|
||||
LOGDEB("exeDocFetcherMake: using config in " << (bconfname) << "\n" );
|
||||
bconf = new ConfSimple(bconfname.c_str(), true);
|
||||
if (!bconf->ok()) {
|
||||
delete bconf;
|
||||
bconf = 0;
|
||||
LOGDEB(("exeDocFetcherMake: bad/no config: %s\n",
|
||||
bconfname.c_str()));
|
||||
LOGDEB("exeDocFetcherMake: bad/no config: " << (bconfname) << "\n" );
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -101,29 +97,28 @@ EXEDocFetcher *exeDocFetcherMake(RclConfig *config, const string& bckid)
|
||||
|
||||
string sfetch;
|
||||
if (!bconf->get("fetch", sfetch, bckid) || sfetch.empty()) {
|
||||
LOGERR(("exeDocFetcherMake: no 'fetch' for [%s]\n", bckid.c_str()));
|
||||
LOGERR("exeDocFetcherMake: no 'fetch' for [" << (bckid) << "]\n" );
|
||||
return 0;
|
||||
}
|
||||
stringToStrings(sfetch, m.sfetch);
|
||||
// We look up the command as we do for filters for now
|
||||
m.sfetch[0] = config->findFilter(m.sfetch[0]);
|
||||
if (!path_isabsolute(m.sfetch[0])) {
|
||||
LOGERR(("exeDocFetcherMake: %s not found in exec path or filters dir\n",
|
||||
m.sfetch[0].c_str()));
|
||||
LOGERR("exeDocFetcherMake: " << (m.sfetch[0]) << " not found in exec path or filters dir\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
string smkid;
|
||||
if (!bconf->get("makesig", smkid, bckid) || smkid.empty()) {
|
||||
LOGDEB(("exeDocFetcherMake: no 'makesig' for [%s]\n", bckid.c_str()));
|
||||
LOGDEB("exeDocFetcherMake: no 'makesig' for [" << (bckid) << "]\n" );
|
||||
return 0;
|
||||
}
|
||||
stringToStrings(smkid, m.smkid);
|
||||
m.smkid[0] = config->findFilter(m.smkid[0]);
|
||||
if (!path_isabsolute(m.smkid[0])) {
|
||||
LOGERR(("exeDocFetcherMake: %s not found in exec path or filters dir\n",
|
||||
m.smkid[0].c_str()));
|
||||
LOGERR("exeDocFetcherMake: " << (m.smkid[0]) << " not found in exec path or filters dir\n" );
|
||||
return 0;
|
||||
}
|
||||
return new EXEDocFetcher(m);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "autoconfig.h"
|
||||
|
||||
|
||||
#include "debuglog.h"
|
||||
#include "log.h"
|
||||
#include "rclconfig.h"
|
||||
|
||||
#include "fetcher.h"
|
||||
@@ -28,7 +28,7 @@
|
||||
DocFetcher *docFetcherMake(RclConfig *config, const Rcl::Doc& idoc)
|
||||
{
|
||||
if (idoc.url.empty()) {
|
||||
LOGERR(("docFetcherMakeg:: no url in doc!\n"));
|
||||
LOGERR("docFetcherMakeg:: no url in doc!\n" );
|
||||
return 0;
|
||||
}
|
||||
string backend;
|
||||
@@ -42,9 +42,9 @@ DocFetcher *docFetcherMake(RclConfig *config, const Rcl::Doc& idoc)
|
||||
} else {
|
||||
DocFetcher *f = exeDocFetcherMake(config, backend);
|
||||
if (!f) {
|
||||
LOGERR(("DocFetcherFactory: unknown backend [%s]\n",
|
||||
backend.c_str()));
|
||||
LOGERR("DocFetcherFactory: unknown backend [" << (backend) << "]\n" );
|
||||
}
|
||||
return f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,12 +19,11 @@
|
||||
#include <errno.h>
|
||||
#include "safesysstat.h"
|
||||
|
||||
#include "debuglog.h"
|
||||
#include "log.h"
|
||||
#include "cstr.h"
|
||||
#include "fetcher.h"
|
||||
#include "fsfetcher.h"
|
||||
#include "fsindexer.h"
|
||||
#include "debuglog.h"
|
||||
#include "pathut.h"
|
||||
|
||||
using std::string;
|
||||
@@ -35,8 +34,7 @@ static bool urltopath(RclConfig* cnf,
|
||||
// The url has to be like file://
|
||||
fn = fileurltolocalpath(idoc.url);
|
||||
if (fn.empty()) {
|
||||
LOGERR(("FSDocFetcher::fetch/sig: non fs url: [%s]\n",
|
||||
idoc.url.c_str()));
|
||||
LOGERR("FSDocFetcher::fetch/sig: non fs url: [" << (idoc.url) << "]\n" );
|
||||
return false;
|
||||
}
|
||||
cnf->setKeyDir(path_getfather(fn));
|
||||
@@ -44,8 +42,7 @@ static bool urltopath(RclConfig* cnf,
|
||||
cnf->getConfParam("followLinks", &follow);
|
||||
|
||||
if (path_fileprops(fn, &st, follow) < 0) {
|
||||
LOGERR(("FSDocFetcher::fetch: stat errno %d for [%s]\n",
|
||||
errno, fn.c_str()));
|
||||
LOGERR("FSDocFetcher::fetch: stat errno " << (errno) << " for [" << (fn) << "]\n" );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -71,3 +68,4 @@ bool FSDocFetcher::makesig(RclConfig* cnf, const Rcl::Doc& idoc, string& sig)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+50
-67
@@ -37,7 +37,7 @@
|
||||
#include "indexer.h"
|
||||
#include "fsindexer.h"
|
||||
#include "transcode.h"
|
||||
#include "debuglog.h"
|
||||
#include "log.h"
|
||||
#include "internfile.h"
|
||||
#include "smallut.h"
|
||||
#include "chrono.h"
|
||||
@@ -106,19 +106,18 @@ FsIndexer::FsIndexer(RclConfig *cnf, Rcl::Db *db, DbIxStatusUpdater *updfunc)
|
||||
m_dwqueue("Split", cnf->getThrConf(RclConfig::ThrSplit).first)
|
||||
#endif // IDX_THREADS
|
||||
{
|
||||
LOGDEB1(("FsIndexer::FsIndexer\n"));
|
||||
LOGDEB1("FsIndexer::FsIndexer\n" );
|
||||
m_havelocalfields = m_config->hasNameAnywhere("localfields");
|
||||
m_config->getConfParam("detectxattronly", &m_detectxattronly);
|
||||
|
||||
#ifdef IDX_THREADS
|
||||
m_stableconfig = new RclConfig(*m_config);
|
||||
m_loglevel = DebugLog::getdbl()->getlevel();
|
||||
m_haveInternQ = m_haveSplitQ = false;
|
||||
int internqlen = cnf->getThrConf(RclConfig::ThrIntern).first;
|
||||
int internthreads = cnf->getThrConf(RclConfig::ThrIntern).second;
|
||||
if (internqlen >= 0) {
|
||||
if (!m_iwqueue.start(internthreads, FsIndexerInternfileWorker, this)) {
|
||||
LOGERR(("FsIndexer::FsIndexer: intern worker start failed\n"));
|
||||
LOGERR("FsIndexer::FsIndexer: intern worker start failed\n" );
|
||||
return;
|
||||
}
|
||||
m_haveInternQ = true;
|
||||
@@ -127,30 +126,28 @@ FsIndexer::FsIndexer(RclConfig *cnf, Rcl::Db *db, DbIxStatusUpdater *updfunc)
|
||||
int splitthreads = cnf->getThrConf(RclConfig::ThrSplit).second;
|
||||
if (splitqlen >= 0) {
|
||||
if (!m_dwqueue.start(splitthreads, FsIndexerDbUpdWorker, this)) {
|
||||
LOGERR(("FsIndexer::FsIndexer: split worker start failed\n"));
|
||||
LOGERR("FsIndexer::FsIndexer: split worker start failed\n" );
|
||||
return;
|
||||
}
|
||||
m_haveSplitQ = true;
|
||||
}
|
||||
LOGDEB(("FsIndexer: threads: haveIQ %d iql %d iqts %d "
|
||||
"haveSQ %d sql %d sqts %d\n", m_haveInternQ, internqlen,
|
||||
internthreads, m_haveSplitQ, splitqlen, splitthreads));
|
||||
LOGDEB("FsIndexer: threads: haveIQ " << (m_haveInternQ) << " iql " << (internqlen) << " iqts " << (internthreads) << " haveSQ " << (m_haveSplitQ) << " sql " << (splitqlen) << " sqts " << (splitthreads) << "\n" );
|
||||
#endif // IDX_THREADS
|
||||
}
|
||||
|
||||
FsIndexer::~FsIndexer()
|
||||
{
|
||||
LOGDEB1(("FsIndexer::~FsIndexer()\n"));
|
||||
LOGDEB1("FsIndexer::~FsIndexer()\n" );
|
||||
|
||||
#ifdef IDX_THREADS
|
||||
void *status;
|
||||
if (m_haveInternQ) {
|
||||
status = m_iwqueue.setTerminateAndWait();
|
||||
LOGDEB0(("FsIndexer: internfile wrkr status: %p (1->ok)\n", status));
|
||||
LOGDEB0("FsIndexer: internfile wrkr status: " << (status) << " (1->ok)\n" );
|
||||
}
|
||||
if (m_haveSplitQ) {
|
||||
status = m_dwqueue.setTerminateAndWait();
|
||||
LOGDEB0(("FsIndexer: dbupd worker status: %p (1->ok)\n", status));
|
||||
LOGDEB0("FsIndexer: dbupd worker status: " << (status) << " (1->ok)\n" );
|
||||
}
|
||||
delete m_stableconfig;
|
||||
#endif // IDX_THREADS
|
||||
@@ -163,7 +160,7 @@ bool FsIndexer::init()
|
||||
if (m_tdl.empty()) {
|
||||
m_tdl = m_config->getTopdirs();
|
||||
if (m_tdl.empty()) {
|
||||
LOGERR(("FsIndexers: no topdirs list defined\n"));
|
||||
LOGERR("FsIndexers: no topdirs list defined\n" );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -194,8 +191,8 @@ bool FsIndexer::index(int flags)
|
||||
|
||||
for (vector<string>::const_iterator it = m_tdl.begin();
|
||||
it != m_tdl.end(); it++) {
|
||||
LOGDEB(("FsIndexer::index: Indexing %s into %s\n", it->c_str(),
|
||||
getDbDir().c_str()));
|
||||
LOGDEB("FsIndexer::index: Indexing " << *it << " into " <<
|
||||
getDbDir() << "\n");
|
||||
|
||||
// Set the current directory in config so that subsequent
|
||||
// getConfParams() will get local values
|
||||
@@ -217,8 +214,8 @@ bool FsIndexer::index(int flags)
|
||||
|
||||
// Walk the directory tree
|
||||
if (m_walker.walk(*it, *this) != FsTreeWalker::FtwOk) {
|
||||
LOGERR(("FsIndexer::index: error while indexing %s: %s\n",
|
||||
it->c_str(), m_walker.getReason().c_str()));
|
||||
LOGERR("FsIndexer::index: error while indexing " << *it <<
|
||||
": " << m_walker.getReason() << "\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -235,12 +232,11 @@ bool FsIndexer::index(int flags)
|
||||
string missing;
|
||||
m_missing->getMissingDescription(missing);
|
||||
if (!missing.empty()) {
|
||||
LOGINFO(("FsIndexer::index missing helper program(s):\n%s\n",
|
||||
missing.c_str()));
|
||||
LOGINFO("FsIndexer::index missing helper program(s):\n" << (missing) << "\n" );
|
||||
}
|
||||
m_config->storeMissingHelperDesc(missing);
|
||||
}
|
||||
LOGINFO(("fsindexer index time: %d mS\n", chron.millis()));
|
||||
LOGINFO("fsindexer index time: " << (chron.millis()) << " mS\n" );
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -261,8 +257,7 @@ static bool matchesSkipped(const vector<string>& tdl,
|
||||
for (vector<string>::const_iterator it = tdl.begin();
|
||||
it != tdl.end(); it++) {
|
||||
// the topdirs members are already canonized.
|
||||
LOGDEB2(("matchesSkipped: comparing ancestor [%s] to "
|
||||
"topdir [%s]\n", mpath.c_str(), it->c_str()));
|
||||
LOGDEB2("matchesSkipped: comparing ancestor [" << (mpath) << "] to topdir [" << (it) << "]\n" );
|
||||
if (!mpath.compare(*it)) {
|
||||
topdir = *it;
|
||||
goto goodpath;
|
||||
@@ -270,8 +265,7 @@ static bool matchesSkipped(const vector<string>& tdl,
|
||||
}
|
||||
|
||||
if (walker.inSkippedPaths(mpath, false)) {
|
||||
LOGDEB(("FsIndexer::indexFiles: skipping [%s] (skpp)\n",
|
||||
path.c_str()));
|
||||
LOGDEB("FsIndexer::indexFiles: skipping [" << (path) << "] (skpp)\n" );
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -285,13 +279,12 @@ static bool matchesSkipped(const vector<string>& tdl,
|
||||
// path did not shorten, something is seriously amiss
|
||||
// (could be an assert actually)
|
||||
if (mpath.length() >= len) {
|
||||
LOGERR(("FsIndexer::indexFile: internal Error: path [%s] did not "
|
||||
"shorten\n", mpath.c_str()));
|
||||
LOGERR("FsIndexer::indexFile: internal Error: path [" << (mpath) << "] did not shorten\n" );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// We get there if neither topdirs nor skippedPaths tests matched
|
||||
LOGDEB(("FsIndexer::indexFiles: skipping [%s] (ntd)\n", path.c_str()));
|
||||
LOGDEB("FsIndexer::indexFiles: skipping [" << (path) << "] (ntd)\n" );
|
||||
return true;
|
||||
|
||||
goodpath:
|
||||
@@ -301,8 +294,7 @@ goodpath:
|
||||
while (mpath.length() >= topdir.length() && mpath.length() > 1) {
|
||||
string fn = path_getsimple(mpath);
|
||||
if (walker.inSkippedNames(fn)) {
|
||||
LOGDEB(("FsIndexer::indexFiles: skipping [%s] (skpn)\n",
|
||||
path.c_str()));
|
||||
LOGDEB("FsIndexer::indexFiles: skipping [" << (path) << "] (skpn)\n" );
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -326,7 +318,7 @@ goodpath:
|
||||
*/
|
||||
bool FsIndexer::indexFiles(list<string>& files, int flags)
|
||||
{
|
||||
LOGDEB(("FsIndexer::indexFiles\n"));
|
||||
LOGDEB("FsIndexer::indexFiles\n" );
|
||||
m_noretryfailed = (flags & ConfIndexer::IxFNoRetryFailed) != 0;
|
||||
bool ret = false;
|
||||
|
||||
@@ -344,7 +336,7 @@ bool FsIndexer::indexFiles(list<string>& files, int flags)
|
||||
walker.setSkippedPaths(m_config->getSkippedPaths());
|
||||
|
||||
for (list<string>::iterator it = files.begin(); it != files.end(); ) {
|
||||
LOGDEB2(("FsIndexer::indexFiles: [%s]\n", it->c_str()));
|
||||
LOGDEB2("FsIndexer::indexFiles: [" << (it) << "]\n" );
|
||||
|
||||
m_config->setKeyDir(path_getfather(*it));
|
||||
if (m_havelocalfields)
|
||||
@@ -364,15 +356,15 @@ bool FsIndexer::indexFiles(list<string>& files, int flags)
|
||||
struct stat stb;
|
||||
int ststat = path_fileprops(*it, &stb, follow);
|
||||
if (ststat != 0) {
|
||||
LOGERR(("FsIndexer::indexFiles: (l)stat %s: %s", it->c_str(),
|
||||
strerror(errno)));
|
||||
LOGERR("FsIndexer::indexFiles: (l)stat " << *it << ": " <<
|
||||
strerror(errno) << "\n");
|
||||
it++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (processone(*it, &stb, FsTreeWalker::FtwRegular) !=
|
||||
FsTreeWalker::FtwOk) {
|
||||
LOGERR(("FsIndexer::indexFiles: processone failed\n"));
|
||||
LOGERR("FsIndexer::indexFiles: processone failed\n" );
|
||||
goto out;
|
||||
}
|
||||
it = files.erase(it);
|
||||
@@ -390,11 +382,11 @@ out:
|
||||
|
||||
// Purge possible orphan documents
|
||||
if (ret == true) {
|
||||
LOGDEB(("Indexfiles: purging orphans\n"));
|
||||
LOGDEB("Indexfiles: purging orphans\n" );
|
||||
const vector<string>& purgecandidates = m_purgeCandidates.getCandidates();
|
||||
for (vector<string>::const_iterator it = purgecandidates.begin();
|
||||
it != purgecandidates.end(); it++) {
|
||||
LOGDEB(("Indexfiles: purging orphans for %s\n", it->c_str()));
|
||||
LOGDEB("Indexfiles: purging orphans for " << *it << "\n");
|
||||
m_db->purgeOrphans(*it);
|
||||
}
|
||||
#ifdef IDX_THREADS
|
||||
@@ -402,7 +394,7 @@ out:
|
||||
#endif // IDX_THREADS
|
||||
}
|
||||
|
||||
LOGDEB(("FsIndexer::indexFiles: done\n"));
|
||||
LOGDEB("FsIndexer::indexFiles: done\n" );
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -410,7 +402,7 @@ out:
|
||||
/** Purge docs for given files out of the database */
|
||||
bool FsIndexer::purgeFiles(list<string>& files)
|
||||
{
|
||||
LOGDEB(("FsIndexer::purgeFiles\n"));
|
||||
LOGDEB("FsIndexer::purgeFiles\n" );
|
||||
bool ret = false;
|
||||
if (!init())
|
||||
return false;
|
||||
@@ -422,7 +414,7 @@ bool FsIndexer::purgeFiles(list<string>& files)
|
||||
// found or deleted, false only in case of actual error
|
||||
bool existed;
|
||||
if (!m_db->purgeFile(udi, &existed)) {
|
||||
LOGERR(("FsIndexer::purgeFiles: Database error\n"));
|
||||
LOGERR("FsIndexer::purgeFiles: Database error\n" );
|
||||
goto out;
|
||||
}
|
||||
// If we actually deleted something, take it off the list
|
||||
@@ -442,14 +434,14 @@ out:
|
||||
m_dwqueue.waitIdle();
|
||||
m_db->waitUpdIdle();
|
||||
#endif // IDX_THREADS
|
||||
LOGDEB(("FsIndexer::purgeFiles: done\n"));
|
||||
LOGDEB("FsIndexer::purgeFiles: done\n" );
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Local fields can be set for fs subtrees in the configuration file
|
||||
void FsIndexer::localfieldsfromconf()
|
||||
{
|
||||
LOGDEB1(("FsIndexer::localfieldsfromconf\n"));
|
||||
LOGDEB1("FsIndexer::localfieldsfromconf\n" );
|
||||
|
||||
string sfields;
|
||||
m_config->getConfParam("localfields", sfields);
|
||||
@@ -469,8 +461,7 @@ void FsIndexer::localfieldsfromconf()
|
||||
it != nmlst.end(); it++) {
|
||||
string nm = m_config->fieldCanon(*it);
|
||||
attrs.get(*it, m_localfields[nm]);
|
||||
LOGDEB2(("FsIndexer::localfieldsfromconf: [%s]->[%s]\n",
|
||||
nm.c_str(), m_localfields[nm].c_str()));
|
||||
LOGDEB2("FsIndexer::localfieldsfromconf: [" << (nm) << "]->[" << (m_localfields[nm]) << "]\n" );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -501,7 +492,6 @@ void *FsIndexerDbUpdWorker(void * fsp)
|
||||
recoll_threadinit();
|
||||
FsIndexer *fip = (FsIndexer*)fsp;
|
||||
WorkQueue<DbUpdTask*> *tqp = &fip->m_dwqueue;
|
||||
DebugLog::getdbl()->setloglevel(fip->m_loglevel);
|
||||
|
||||
DbUpdTask *tsk;
|
||||
for (;;) {
|
||||
@@ -510,9 +500,9 @@ void *FsIndexerDbUpdWorker(void * fsp)
|
||||
tqp->workerExit();
|
||||
return (void*)1;
|
||||
}
|
||||
LOGDEB0(("FsIndexerDbUpdWorker: task ql %d\n", int(qsz)));
|
||||
LOGDEB0("FsIndexerDbUpdWorker: task ql " << (int(qsz)) << "\n" );
|
||||
if (!fip->m_db->addOrUpdate(tsk->udi, tsk->parent_udi, tsk->doc)) {
|
||||
LOGERR(("FsIndexerDbUpdWorker: addOrUpdate failed\n"));
|
||||
LOGERR("FsIndexerDbUpdWorker: addOrUpdate failed\n" );
|
||||
tqp->workerExit();
|
||||
return (void*)0;
|
||||
}
|
||||
@@ -525,7 +515,6 @@ void *FsIndexerInternfileWorker(void * fsp)
|
||||
recoll_threadinit();
|
||||
FsIndexer *fip = (FsIndexer*)fsp;
|
||||
WorkQueue<InternfileTask*> *tqp = &fip->m_iwqueue;
|
||||
DebugLog::getdbl()->setloglevel(fip->m_loglevel);
|
||||
RclConfig myconf(*(fip->m_stableconfig));
|
||||
|
||||
InternfileTask *tsk = 0;
|
||||
@@ -534,15 +523,15 @@ void *FsIndexerInternfileWorker(void * fsp)
|
||||
tqp->workerExit();
|
||||
return (void*)1;
|
||||
}
|
||||
LOGDEB0(("FsIndexerInternfileWorker: task fn %s\n", tsk->fn.c_str()));
|
||||
LOGDEB0("FsIndexerInternfileWorker: task fn " << (tsk->fn) << "\n" );
|
||||
if (fip->processonefile(&myconf, tsk->fn, &tsk->statbuf,
|
||||
tsk->localfields) !=
|
||||
FsTreeWalker::FtwOk) {
|
||||
LOGERR(("FsIndexerInternfileWorker: processone failed\n"));
|
||||
LOGERR("FsIndexerInternfileWorker: processone failed\n" );
|
||||
tqp->workerExit();
|
||||
return (void*)0;
|
||||
}
|
||||
LOGDEB1(("FsIndexerInternfileWorker: done fn %s\n", tsk->fn.c_str()));
|
||||
LOGDEB1("FsIndexerInternfileWorker: done fn " << (tsk->fn) << "\n" );
|
||||
delete tsk;
|
||||
}
|
||||
}
|
||||
@@ -613,15 +602,11 @@ static string compute_utf8fn(RclConfig *config, const string& fn)
|
||||
string utf8fn;
|
||||
int ercnt;
|
||||
if (!transcode(path_getsimple(fn), utf8fn, charset, "UTF-8", &ercnt)) {
|
||||
LOGERR(("processone: fn transcode failure from [%s] to UTF-8: %s\n",
|
||||
charset.c_str(), path_getsimple(fn).c_str()));
|
||||
LOGERR("processone: fn transcode failure from [" << (charset) << "] to UTF-8: " << (path_getsimple(fn)) << "\n" );
|
||||
} else if (ercnt) {
|
||||
LOGDEB(("processone: fn transcode %d errors from [%s] to UTF-8: %s\n",
|
||||
ercnt, charset.c_str(), path_getsimple(fn).c_str()));
|
||||
LOGDEB("processone: fn transcode " << (ercnt) << " errors from [" << (charset) << "] to UTF-8: " << (path_getsimple(fn)) << "\n" );
|
||||
}
|
||||
LOGDEB2(("processone: fn transcoded from [%s] to [%s] (%s->%s)\n",
|
||||
path_getsimple(fn).c_str(), utf8fn.c_str(), charset.c_str(),
|
||||
"UTF-8"));
|
||||
LOGDEB2("processone: fn transcoded from [" << (path_getsimple(fn)) << "] to [" << (utf8fn) << "] (" << (charset) << "->" << ("UTF-8") << ")\n" );
|
||||
return utf8fn;
|
||||
}
|
||||
|
||||
@@ -663,8 +648,7 @@ FsIndexer::processonefile(RclConfig *config,
|
||||
bool xattronly = m_detectxattronly && !m_db->inFullReset() &&
|
||||
existingDoc && needupdate && (stp->st_mtime < stp->st_ctime);
|
||||
|
||||
LOGDEB(("processone: needupdate %d noretry %d existing %d oldsig [%s]\n",
|
||||
needupdate, m_noretryfailed, existingDoc, oldsig.c_str()));
|
||||
LOGDEB("processone: needupdate " << (needupdate) << " noretry " << (m_noretryfailed) << " existing " << (existingDoc) << " oldsig [" << (oldsig) << "]\n" );
|
||||
|
||||
// If noretryfailed is set, check for a file which previously
|
||||
// failed to index, and avoid re-processing it
|
||||
@@ -674,14 +658,14 @@ FsIndexer::processonefile(RclConfig *config,
|
||||
// actually changed, we always retry (maybe it was fixed)
|
||||
string nold = oldsig.substr(0, oldsig.size()-1);
|
||||
if (!nold.compare(sig)) {
|
||||
LOGDEB(("processone: not retrying previously failed file\n"));
|
||||
LOGDEB("processone: not retrying previously failed file\n" );
|
||||
m_db->setExistingFlags(udi, existingDoc);
|
||||
needupdate = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!needupdate) {
|
||||
LOGDEB0(("processone: up to date: %s\n", fn.c_str()));
|
||||
LOGDEB0("processone: up to date: " << (fn) << "\n" );
|
||||
if (m_updater) {
|
||||
#ifdef IDX_THREADS
|
||||
PTMutexLocker locker(m_updater->m_mutex);
|
||||
@@ -696,8 +680,7 @@ FsIndexer::processonefile(RclConfig *config,
|
||||
return FsTreeWalker::FtwOk;
|
||||
}
|
||||
|
||||
LOGDEB0(("processone: processing: [%s] %s\n",
|
||||
displayableBytes(off_t(stp->st_size)).c_str(), fn.c_str()));
|
||||
LOGDEB0("processone: processing: [" << (displayableBytes(off_t(stp->st_size))) << "] " << (fn) << "\n" );
|
||||
|
||||
string utf8fn = compute_utf8fn(config, fn);
|
||||
|
||||
@@ -729,7 +712,7 @@ FsIndexer::processonefile(RclConfig *config,
|
||||
try {
|
||||
fis = interner.internfile(doc);
|
||||
} catch (CancelExcept) {
|
||||
LOGERR(("fsIndexer::processone: interrupted\n"));
|
||||
LOGERR("fsIndexer::processone: interrupted\n" );
|
||||
return FsTreeWalker::FtwStop;
|
||||
}
|
||||
|
||||
@@ -800,7 +783,7 @@ FsIndexer::processonefile(RclConfig *config,
|
||||
DbUpdTask *tp = new DbUpdTask(udi, doc.ipath.empty() ?
|
||||
cstr_null : parent_udi, doc);
|
||||
if (!m_dwqueue.put(tp)) {
|
||||
LOGERR(("processonefile: wqueue.put failed\n"));
|
||||
LOGERR("processonefile: wqueue.put failed\n" );
|
||||
return FsTreeWalker::FtwError;
|
||||
}
|
||||
} else {
|
||||
@@ -839,8 +822,7 @@ FsIndexer::processonefile(RclConfig *config,
|
||||
// If this doc existed and it's a container, recording for
|
||||
// possible subdoc purge (this will be used only if we don't do a
|
||||
// db-wide purge, e.g. if we're called from indexfiles()).
|
||||
LOGDEB2(("processOnefile: existingDoc %d hadNonNullIpath %d\n",
|
||||
existingDoc, hadNonNullIpath));
|
||||
LOGDEB2("processOnefile: existingDoc " << (existingDoc) << " hadNonNullIpath " << (hadNonNullIpath) << "\n" );
|
||||
if (existingDoc && hadNonNullIpath) {
|
||||
m_purgeCandidates.record(parent_udi);
|
||||
}
|
||||
@@ -853,7 +835,7 @@ FsIndexer::processonefile(RclConfig *config,
|
||||
// If xattronly is set, ONLY the extattr metadata is valid and will be used
|
||||
// by the following step.
|
||||
if (xattronly || hadNullIpath == false) {
|
||||
LOGDEB(("Creating empty doc for file or pure xattr update\n"));
|
||||
LOGDEB("Creating empty doc for file or pure xattr update\n" );
|
||||
Rcl::Doc fileDoc;
|
||||
if (xattronly) {
|
||||
map<string, string> xfields;
|
||||
@@ -889,3 +871,4 @@ FsIndexer::processonefile(RclConfig *config,
|
||||
|
||||
return FsTreeWalker::FtwOk;
|
||||
}
|
||||
|
||||
|
||||
@@ -142,7 +142,6 @@ class FsIndexer : public FsTreeWalkerCB {
|
||||
#ifdef IDX_THREADS
|
||||
friend void *FsIndexerDbUpdWorker(void*);
|
||||
friend void *FsIndexerInternfileWorker(void*);
|
||||
int m_loglevel;
|
||||
WorkQueue<InternfileTask*> m_iwqueue;
|
||||
WorkQueue<DbUpdTask*> m_dwqueue;
|
||||
bool m_haveInternQ;
|
||||
|
||||
+19
-28
@@ -22,7 +22,7 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include "cstr.h"
|
||||
#include "debuglog.h"
|
||||
#include "log.h"
|
||||
#include "indexer.h"
|
||||
#include "fsindexer.h"
|
||||
#ifndef DISABLE_WEB_INDEXER
|
||||
@@ -60,13 +60,13 @@ bool ConfIndexer::runFirstIndexing()
|
||||
{
|
||||
// Indexing status file existing and not empty ?
|
||||
if (path_filesize(m_config->getIdxStatusFile()) > 0) {
|
||||
LOGDEB0(("ConfIndexer::runFirstIndexing: no: status file not empty\n"));
|
||||
LOGDEB0("ConfIndexer::runFirstIndexing: no: status file not empty\n" );
|
||||
return false;
|
||||
}
|
||||
// And only do this if the user has kept the default topdirs (~).
|
||||
vector<string> tdl = m_config->getTopdirs();
|
||||
if (tdl.size() != 1 || tdl[0].compare(path_canon(path_tildexpand("~")))) {
|
||||
LOGDEB0(("ConfIndexer::runFirstIndexing: no: not home only\n"));
|
||||
LOGDEB0("ConfIndexer::runFirstIndexing: no: not home only\n" );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -74,7 +74,7 @@ bool ConfIndexer::runFirstIndexing()
|
||||
|
||||
bool ConfIndexer::firstFsIndexingSequence()
|
||||
{
|
||||
LOGDEB(("ConfIndexer::firstFsIndexingSequence\n"));
|
||||
LOGDEB("ConfIndexer::firstFsIndexingSequence\n" );
|
||||
deleteZ(m_fsindexer);
|
||||
m_fsindexer = new FsIndexer(m_config, &m_db, m_updater);
|
||||
if (!m_fsindexer) {
|
||||
@@ -92,8 +92,7 @@ bool ConfIndexer::index(bool resetbefore, ixType typestorun, int flags)
|
||||
{
|
||||
Rcl::Db::OpenMode mode = resetbefore ? Rcl::Db::DbTrunc : Rcl::Db::DbUpd;
|
||||
if (!m_db.open(mode)) {
|
||||
LOGERR(("ConfIndexer: error opening database %s : %s\n",
|
||||
m_config->getDbDir().c_str(), m_db.getReason().c_str()));
|
||||
LOGERR("ConfIndexer: error opening database " << (m_config->getDbDir()) << " : " << (m_db.getReason()) << "\n" );
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -135,8 +134,7 @@ bool ConfIndexer::index(bool resetbefore, ixType typestorun, int flags)
|
||||
if (m_updater)
|
||||
m_updater->update(DbIxStatus::DBIXS_CLOSING, string());
|
||||
if (!m_db.close()) {
|
||||
LOGERR(("ConfIndexer::index: error closing database in %s\n",
|
||||
m_config->getDbDir().c_str()));
|
||||
LOGERR("ConfIndexer::index: error closing database in " << (m_config->getDbDir()) << "\n" );
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -163,8 +161,7 @@ bool ConfIndexer::indexFiles(list<string>& ifiles, int flag)
|
||||
myfiles.sort();
|
||||
|
||||
if (!m_db.open(Rcl::Db::DbUpd)) {
|
||||
LOGERR(("ConfIndexer: indexFiles error opening database %s\n",
|
||||
m_config->getDbDir().c_str()));
|
||||
LOGERR("ConfIndexer: indexFiles error opening database " << (m_config->getDbDir()) << "\n" );
|
||||
return false;
|
||||
}
|
||||
m_config->setKeyDir(cstr_null);
|
||||
@@ -173,8 +170,7 @@ bool ConfIndexer::indexFiles(list<string>& ifiles, int flag)
|
||||
m_fsindexer = new FsIndexer(m_config, &m_db, m_updater);
|
||||
if (m_fsindexer)
|
||||
ret = m_fsindexer->indexFiles(myfiles, flag);
|
||||
LOGDEB2(("ConfIndexer::indexFiles: fsindexer returned %d, "
|
||||
"%d files remainining\n", ret, myfiles.size()));
|
||||
LOGDEB2("ConfIndexer::indexFiles: fsindexer returned " << (ret) << ", " << (myfiles.size()) << " files remainining\n" );
|
||||
#ifndef DISABLE_WEB_INDEXER
|
||||
|
||||
if (m_dobeagle && !myfiles.empty() && !(flag & IxFNoWeb)) {
|
||||
@@ -189,8 +185,7 @@ bool ConfIndexer::indexFiles(list<string>& ifiles, int flag)
|
||||
#endif
|
||||
// The close would be done in our destructor, but we want status here
|
||||
if (!m_db.close()) {
|
||||
LOGERR(("ConfIndexer::index: error closing database in %s\n",
|
||||
m_config->getDbDir().c_str()));
|
||||
LOGERR("ConfIndexer::index: error closing database in " << (m_config->getDbDir()) << "\n" );
|
||||
return false;
|
||||
}
|
||||
ifiles = myfiles;
|
||||
@@ -214,8 +209,7 @@ bool ConfIndexer::docsToPaths(vector<Rcl::Doc> &docs, vector<string> &paths)
|
||||
|
||||
// Filesystem document. The url has to be like file://
|
||||
if (idoc.url.find(cstr_fileu) != 0) {
|
||||
LOGERR(("idx::docsToPaths: FS backend and non fs url: [%s]\n",
|
||||
idoc.url.c_str()));
|
||||
LOGERR("idx::docsToPaths: FS backend and non fs url: [" << (idoc.url) << "]\n" );
|
||||
continue;
|
||||
}
|
||||
paths.push_back(idoc.url.substr(7, string::npos));
|
||||
@@ -247,8 +241,7 @@ bool ConfIndexer::purgeFiles(std::list<string> &files, int flag)
|
||||
myfiles.sort();
|
||||
|
||||
if (!m_db.open(Rcl::Db::DbUpd)) {
|
||||
LOGERR(("ConfIndexer: purgeFiles error opening database %s\n",
|
||||
m_config->getDbDir().c_str()));
|
||||
LOGERR("ConfIndexer: purgeFiles error opening database " << (m_config->getDbDir()) << "\n" );
|
||||
return false;
|
||||
}
|
||||
bool ret = false;
|
||||
@@ -272,8 +265,7 @@ bool ConfIndexer::purgeFiles(std::list<string> &files, int flag)
|
||||
|
||||
// The close would be done in our destructor, but we want status here
|
||||
if (!m_db.close()) {
|
||||
LOGERR(("ConfIndexer::purgefiles: error closing database in %s\n",
|
||||
m_config->getDbDir().c_str()));
|
||||
LOGERR("ConfIndexer::purgefiles: error closing database in " << (m_config->getDbDir()) << "\n" );
|
||||
return false;
|
||||
}
|
||||
return ret;
|
||||
@@ -286,7 +278,7 @@ bool ConfIndexer::createStemmingDatabases()
|
||||
string slangs;
|
||||
if (m_config->getConfParam("indexstemminglanguages", slangs)) {
|
||||
if (!m_db.open(Rcl::Db::DbUpd)) {
|
||||
LOGERR(("ConfIndexer::createStemmingDb: could not open db\n"))
|
||||
LOGERR("ConfIndexer::createStemmingDb: could not open db\n" );
|
||||
return false;
|
||||
}
|
||||
vector<string> langs;
|
||||
@@ -319,7 +311,7 @@ bool ConfIndexer::createStemDb(const string &lang)
|
||||
// module, either from a configuration variable or the NLS environment.
|
||||
bool ConfIndexer::createAspellDict()
|
||||
{
|
||||
LOGDEB2(("ConfIndexer::createAspellDict()\n"));
|
||||
LOGDEB2("ConfIndexer::createAspellDict()\n" );
|
||||
#ifdef RCL_USE_ASPELL
|
||||
// For the benefit of the real-time indexer, we only initialize
|
||||
// noaspell from the configuration once. It can then be set to
|
||||
@@ -334,22 +326,20 @@ bool ConfIndexer::createAspellDict()
|
||||
return true;
|
||||
|
||||
if (!m_db.open(Rcl::Db::DbRO)) {
|
||||
LOGERR(("ConfIndexer::createAspellDict: could not open db\n"));
|
||||
LOGERR("ConfIndexer::createAspellDict: could not open db\n" );
|
||||
return false;
|
||||
}
|
||||
|
||||
Aspell aspell(m_config);
|
||||
string reason;
|
||||
if (!aspell.init(reason)) {
|
||||
LOGERR(("ConfIndexer::createAspellDict: aspell init failed: %s\n",
|
||||
reason.c_str()));
|
||||
LOGERR("ConfIndexer::createAspellDict: aspell init failed: " << (reason) << "\n" );
|
||||
noaspell = true;
|
||||
return false;
|
||||
}
|
||||
LOGDEB(("ConfIndexer::createAspellDict: creating dictionary\n"));
|
||||
LOGDEB("ConfIndexer::createAspellDict: creating dictionary\n" );
|
||||
if (!aspell.buildDict(m_db, reason)) {
|
||||
LOGERR(("ConfIndexer::createAspellDict: aspell buildDict failed: %s\n",
|
||||
reason.c_str()));
|
||||
LOGERR("ConfIndexer::createAspellDict: aspell buildDict failed: " << (reason) << "\n" );
|
||||
noaspell = true;
|
||||
return false;
|
||||
}
|
||||
@@ -361,3 +351,4 @@ vector<string> ConfIndexer::getStemmerNames()
|
||||
{
|
||||
return Rcl::Db::getStemmerNames();
|
||||
}
|
||||
|
||||
|
||||
+13
-14
@@ -26,7 +26,7 @@
|
||||
using namespace std;
|
||||
|
||||
#include "mimetype.h"
|
||||
#include "debuglog.h"
|
||||
#include "log.h"
|
||||
#include "execmd.h"
|
||||
#include "rclconfig.h"
|
||||
#include "smallut.h"
|
||||
@@ -64,7 +64,7 @@ static string mimetypefromdata(RclConfig *cfg, const string &fn, bool usfc)
|
||||
vector<string> cmd;
|
||||
string scommand;
|
||||
if (cfg->getConfParam("systemfilecommand", scommand)) {
|
||||
LOGDEB2(("mimetype: syscmd from config: %s\n", scommand.c_str()));
|
||||
LOGDEB2("mimetype: syscmd from config: " << (scommand) << "\n" );
|
||||
stringToStrings(scommand, cmd);
|
||||
string exe;
|
||||
if (cmd.empty()) {
|
||||
@@ -76,19 +76,17 @@ static string mimetypefromdata(RclConfig *cfg, const string &fn, bool usfc)
|
||||
}
|
||||
cmd.push_back(fn);
|
||||
} else {
|
||||
LOGDEB(("mimetype:systemfilecommand not found, using %s\n",
|
||||
stringsToString(tradfilecmd).c_str()));
|
||||
LOGDEB("mimetype:systemfilecommand not found, using " << (stringsToString(tradfilecmd)) << "\n" );
|
||||
cmd = tradfilecmd;
|
||||
}
|
||||
|
||||
string result;
|
||||
if (!ExecCmd::backtick(cmd, result)) {
|
||||
LOGERR(("mimetypefromdata: exec %s failed\n",
|
||||
stringsToString(cmd).c_str()));
|
||||
LOGERR("mimetypefromdata: exec " << (stringsToString(cmd)) << " failed\n" );
|
||||
return string();
|
||||
}
|
||||
trimstring(result, " \t\n\r");
|
||||
LOGDEB2(("mimetype: systemfilecommand output [%s]\n", result.c_str()));
|
||||
LOGDEB2("mimetype: systemfilecommand output [" << (result) << "]\n" );
|
||||
|
||||
// The normal output from "file -i" looks like the following:
|
||||
// thefilename.xxx: text/plain; charset=us-ascii
|
||||
@@ -109,8 +107,7 @@ static string mimetypefromdata(RclConfig *cfg, const string &fn, bool usfc)
|
||||
if (result.find(fn) != 0) {
|
||||
// Garbage "file" output. Maybe the result of a charset
|
||||
// conversion attempt?
|
||||
LOGERR(("mimetype: can't interpret 'file' output: [%s]\n",
|
||||
result.c_str()));
|
||||
LOGERR("mimetype: can't interpret 'file' output: [" << (result) << "]\n" );
|
||||
return string();
|
||||
}
|
||||
result = result.substr(fn.size());
|
||||
@@ -164,9 +161,9 @@ string mimetype(const string &fn, const struct stat *stp,
|
||||
// Extended attribute has priority on everything, as per:
|
||||
// http://freedesktop.org/wiki/CommonExtendedAttributes
|
||||
if (pxattr::get(fn, "mime_type", &mtype)) {
|
||||
LOGDEB0(("Mimetype: 'mime_type' xattr : [%s]\n", mtype.c_str()));
|
||||
LOGDEB0("Mimetype: 'mime_type' xattr : [" << (mtype) << "]\n" );
|
||||
if (mtype.empty()) {
|
||||
LOGDEB0(("Mimetype: getxattr() returned empty mime type !\n"));
|
||||
LOGDEB0("Mimetype: getxattr() returned empty mime type !\n" );
|
||||
} else {
|
||||
return mtype;
|
||||
}
|
||||
@@ -174,12 +171,12 @@ string mimetype(const string &fn, const struct stat *stp,
|
||||
#endif
|
||||
|
||||
if (cfg == 0) {
|
||||
LOGERR(("Mimetype: null config ??\n"));
|
||||
LOGERR("Mimetype: null config ??\n" );
|
||||
return mtype;
|
||||
}
|
||||
|
||||
if (cfg->inStopSuffixes(fn)) {
|
||||
LOGDEB(("mimetype: fn [%s] in stopsuffixes\n", fn.c_str()));
|
||||
LOGDEB("mimetype: fn [" << (fn) << "] in stopsuffixes\n" );
|
||||
return mtype;
|
||||
}
|
||||
|
||||
@@ -211,7 +208,8 @@ string mimetype(const string &fn, const struct stat *stp,
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
|
||||
#include "debuglog.h"
|
||||
#include "log.h"
|
||||
|
||||
#include "rclconfig.h"
|
||||
#include "rclinit.h"
|
||||
#include "mimetype.h"
|
||||
@@ -245,3 +243,4 @@ int main(int argc, const char **argv)
|
||||
|
||||
|
||||
#endif // TEST
|
||||
|
||||
|
||||
+23
-24
@@ -37,9 +37,10 @@
|
||||
using std::list;
|
||||
using std::vector;
|
||||
|
||||
#include "debuglog.h"
|
||||
#include "log.h"
|
||||
#include "rclmon.h"
|
||||
#include "debuglog.h"
|
||||
#include "log.h"
|
||||
|
||||
#include "execmd.h"
|
||||
#include "recollindex.h"
|
||||
#include "pathut.h"
|
||||
@@ -167,7 +168,7 @@ void RclEQData::readDelayPats(int dfltsecs)
|
||||
|
||||
vector<string> dplist;
|
||||
if (!stringToStrings(patstring, dplist)) {
|
||||
LOGERR(("rclEQData: bad pattern list: [%s]\n", patstring.c_str()));
|
||||
LOGERR("rclEQData: bad pattern list: [" << (patstring) << "]\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -182,8 +183,7 @@ void RclEQData::readDelayPats(int dfltsecs)
|
||||
dp.seconds = dfltsecs;
|
||||
}
|
||||
m_delaypats.push_back(dp);
|
||||
LOGDEB2(("rclmon::readDelayPats: add [%s] %d\n",
|
||||
dp.pattern.c_str(), dp.seconds));
|
||||
LOGDEB2("rclmon::readDelayPats: add [" << (dp.pattern) << "] " << (dp.seconds) << "\n" );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,14 +246,12 @@ bool RclMonEventQueue::wait(int seconds, bool *top)
|
||||
MONDEB(("RclMonEventQueue:: timeout\n"));
|
||||
return true;
|
||||
}
|
||||
LOGERR(("RclMonEventQueue::wait:pthread_cond_timedwait failed"
|
||||
"with err %d\n", err));
|
||||
LOGERR("RclMonEventQueue::wait:pthread_cond_timedwait failedwith err " << (err) << "\n" );
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if ((err = pthread_cond_wait(&m_data->m_cond, &m_data->m_mutex))) {
|
||||
LOGERR(("RclMonEventQueue::wait: pthread_cond_wait failed"
|
||||
"with err %d\n", err));
|
||||
LOGERR("RclMonEventQueue::wait: pthread_cond_wait failedwith err " << (err) << "\n" );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -265,7 +263,7 @@ bool RclMonEventQueue::lock()
|
||||
{
|
||||
MONDEB(("RclMonEventQueue:: lock\n"));
|
||||
if (pthread_mutex_lock(&m_data->m_mutex)) {
|
||||
LOGERR(("RclMonEventQueue::lock: pthread_mutex_lock failed\n"));
|
||||
LOGERR("RclMonEventQueue::lock: pthread_mutex_lock failed\n" );
|
||||
return false;
|
||||
}
|
||||
MONDEB(("RclMonEventQueue:: lock return\n"));
|
||||
@@ -276,7 +274,7 @@ bool RclMonEventQueue::unlock()
|
||||
{
|
||||
MONDEB(("RclMonEventQueue:: unlock\n"));
|
||||
if (pthread_mutex_unlock(&m_data->m_mutex)) {
|
||||
LOGERR(("RclMonEventQueue::lock: pthread_mutex_unlock failed\n"));
|
||||
LOGERR("RclMonEventQueue::lock: pthread_mutex_unlock failed\n" );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -298,15 +296,15 @@ RclConfig *RclMonEventQueue::getConfig()
|
||||
bool RclMonEventQueue::ok()
|
||||
{
|
||||
if (m_data == 0) {
|
||||
LOGINFO(("RclMonEventQueue: not ok: bad state\n"));
|
||||
LOGINFO("RclMonEventQueue: not ok: bad state\n" );
|
||||
return false;
|
||||
}
|
||||
if (stopindexing) {
|
||||
LOGINFO(("RclMonEventQueue: not ok: stop request\n"));
|
||||
LOGINFO("RclMonEventQueue: not ok: stop request\n" );
|
||||
return false;
|
||||
}
|
||||
if (!m_data->m_ok) {
|
||||
LOGINFO(("RclMonEventQueue: not ok: queue terminated\n"));
|
||||
LOGINFO("RclMonEventQueue: not ok: queue terminated\n" );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -489,15 +487,15 @@ bool startMonitor(RclConfig *conf, int opts)
|
||||
rclEQ.setopts(opts);
|
||||
|
||||
if (pthread_create(&rcv_thrid, 0, &rclMonRcvRun, &rclEQ) != 0) {
|
||||
LOGERR(("startMonitor: cant create event-receiving thread\n"));
|
||||
LOGERR("startMonitor: cant create event-receiving thread\n" );
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!rclEQ.lock()) {
|
||||
LOGERR(("startMonitor: cant lock queue ???\n"));
|
||||
LOGERR("startMonitor: cant lock queue ???\n" );
|
||||
return false;
|
||||
}
|
||||
LOGDEB(("start_monitoring: entering main loop\n"));
|
||||
LOGDEB("start_monitoring: entering main loop\n" );
|
||||
|
||||
bool timedout;
|
||||
time_t lastauxtime = time(0);
|
||||
@@ -515,7 +513,7 @@ bool startMonitor(RclConfig *conf, int opts)
|
||||
#ifndef _WIN32
|
||||
bool x11dead = !(opts & RCLMON_NOX11) && !x11IsAlive();
|
||||
if (x11dead)
|
||||
LOGDEB(("RclMonprc: x11 is dead\n"));
|
||||
LOGDEB("RclMonprc: x11 is dead\n" );
|
||||
#else
|
||||
bool x11dead = false;
|
||||
#endif
|
||||
@@ -533,11 +531,11 @@ bool startMonitor(RclConfig *conf, int opts)
|
||||
switch (ev.evtype()) {
|
||||
case RclMonEvent::RCLEVT_MODIFY:
|
||||
case RclMonEvent::RCLEVT_DIRCREATE:
|
||||
LOGDEB0(("Monitor: Modify/Check on %s\n", ev.m_path.c_str()));
|
||||
LOGDEB0("Monitor: Modify/Check on " << (ev.m_path) << "\n" );
|
||||
modified.push_back(ev.m_path);
|
||||
break;
|
||||
case RclMonEvent::RCLEVT_DELETE:
|
||||
LOGDEB0(("Monitor: Delete on %s\n", ev.m_path.c_str()));
|
||||
LOGDEB0("Monitor: Delete on " << (ev.m_path) << "\n" );
|
||||
// If this is for a directory (which the caller should
|
||||
// tell us because he knows), we should purge the db
|
||||
// of all the subtree, because on a directory rename,
|
||||
@@ -556,7 +554,7 @@ bool startMonitor(RclConfig *conf, int opts)
|
||||
}
|
||||
break;
|
||||
default:
|
||||
LOGDEB(("Monitor: got Other on [%s]\n", ev.m_path.c_str()));
|
||||
LOGDEB("Monitor: got Other on [" << (ev.m_path) << "]\n" );
|
||||
}
|
||||
}
|
||||
// Unlock queue before processing lists
|
||||
@@ -603,7 +601,7 @@ bool startMonitor(RclConfig *conf, int opts)
|
||||
|
||||
// Check for a config change
|
||||
if (!(opts & RCLMON_NOCONFCHECK) && o_reexec && conf->sourceChanged()) {
|
||||
LOGDEB(("Rclmonprc: config changed, reexecuting myself\n"));
|
||||
LOGDEB("Rclmonprc: config changed, reexecuting myself\n" );
|
||||
// We never want to have a -n option after a config
|
||||
// change. -n was added by the reexec after the initial
|
||||
// pass even if it was not given on the command line
|
||||
@@ -613,7 +611,7 @@ bool startMonitor(RclConfig *conf, int opts)
|
||||
// Lock queue before waiting again
|
||||
rclEQ.lock();
|
||||
}
|
||||
LOGDEB(("Rclmonprc: calling queue setTerminate\n"));
|
||||
LOGDEB("Rclmonprc: calling queue setTerminate\n" );
|
||||
rclEQ.setTerminate();
|
||||
|
||||
// We used to wait for the receiver thread here before returning,
|
||||
@@ -622,8 +620,9 @@ bool startMonitor(RclConfig *conf, int opts)
|
||||
// we ever need several monitor invocations in the same process
|
||||
// (can't foresee any reason why we'd want to do this).
|
||||
// pthread_join(rcv_thrid, 0);
|
||||
LOGDEB(("Monitor: returning\n"));
|
||||
LOGDEB("Monitor: returning\n" );
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // RCL_MONITOR
|
||||
|
||||
|
||||
+29
-47
@@ -24,7 +24,7 @@
|
||||
#include "safesysstat.h"
|
||||
#include "safeunistd.h"
|
||||
|
||||
#include "debuglog.h"
|
||||
#include "log.h"
|
||||
#include "rclmon.h"
|
||||
#include "rclinit.h"
|
||||
#include "fstreewalk.h"
|
||||
@@ -148,26 +148,17 @@ void *rclMonRcvRun(void *q)
|
||||
{
|
||||
RclMonEventQueue *queue = (RclMonEventQueue *)q;
|
||||
|
||||
LOGDEB(("rclMonRcvRun: running\n"));
|
||||
LOGDEB("rclMonRcvRun: running\n" );
|
||||
recoll_threadinit();
|
||||
// Make a local copy of the configuration as it doesn't like
|
||||
// concurrent accesses. It's ok to copy it here as the other
|
||||
// thread will not work before we have sent events.
|
||||
RclConfig lconfig(*queue->getConfig());
|
||||
|
||||
string loglevel;
|
||||
lconfig.getConfParam(string("daemloglevel"), loglevel);
|
||||
if (loglevel.empty())
|
||||
lconfig.getConfParam(string("loglevel"), loglevel);
|
||||
if (!loglevel.empty()) {
|
||||
int lev = atoi(loglevel.c_str());
|
||||
DebugLog::getdbl()->setloglevel(lev);
|
||||
}
|
||||
|
||||
// Create the fam/whatever interface object
|
||||
RclMonitor *mon;
|
||||
if ((mon = makeMonitor()) == 0) {
|
||||
LOGERR(("rclMonRcvRun: makeMonitor failed\n"));
|
||||
LOGERR("rclMonRcvRun: makeMonitor failed\n" );
|
||||
queue->setTerminate();
|
||||
return 0;
|
||||
}
|
||||
@@ -176,8 +167,7 @@ void *rclMonRcvRun(void *q)
|
||||
// Get top directories from config
|
||||
vector<string> tdl = lconfig.getTopdirs();
|
||||
if (tdl.empty()) {
|
||||
LOGERR(("rclMonRcvRun:: top directory list (topdirs param.) not"
|
||||
"found in config or Directory list parse error"));
|
||||
LOGERR("rclMonRcvRun:: top directory list (topdirs param.) notfound in config or Directory list parse error" );
|
||||
queue->setTerminate();
|
||||
return 0;
|
||||
}
|
||||
@@ -196,14 +186,13 @@ void *rclMonRcvRun(void *q)
|
||||
} else {
|
||||
walker.setOpts(FsTreeWalker::FtwOptNone);
|
||||
}
|
||||
LOGDEB(("rclMonRcvRun: walking %s\n", it->c_str()));
|
||||
LOGDEB("rclMonRcvRun: walking " << *it << "\n" );
|
||||
if (walker.walk(*it, walkcb) != FsTreeWalker::FtwOk) {
|
||||
LOGERR(("rclMonRcvRun: tree walk failed\n"));
|
||||
LOGERR("rclMonRcvRun: tree walk failed\n" );
|
||||
goto terminate;
|
||||
}
|
||||
if (walker.getErrCnt() > 0) {
|
||||
LOGINFO(("rclMonRcvRun: fs walker errors: %s\n",
|
||||
walker.getReason().c_str()));
|
||||
LOGINFO("rclMonRcvRun: fs walker errors: " << (walker.getReason()) << "\n" );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,7 +202,7 @@ void *rclMonRcvRun(void *q)
|
||||
if (doweb) {
|
||||
string webqueuedir = lconfig.getWebQueueDir();
|
||||
if (!mon->addWatch(webqueuedir, true)) {
|
||||
LOGERR(("rclMonRcvRun: addwatch (webqueuedir) failed\n"));
|
||||
LOGERR("rclMonRcvRun: addwatch (webqueuedir) failed\n" );
|
||||
if (mon->saved_errno != EACCES && mon->saved_errno != ENOENT)
|
||||
goto terminate;
|
||||
}
|
||||
@@ -249,16 +238,13 @@ void *rclMonRcvRun(void *q)
|
||||
// it seems that fam/gamin is doing the job for us so
|
||||
// that we are generating double events here (no big
|
||||
// deal as prc will sort/merge).
|
||||
LOGDEB(("rclMonRcvRun: walking new dir %s\n",
|
||||
ev.m_path.c_str()));
|
||||
LOGDEB("rclMonRcvRun: walking new dir " << (ev.m_path) << "\n" );
|
||||
if (walker.walk(ev.m_path, walkcb) != FsTreeWalker::FtwOk) {
|
||||
LOGERR(("rclMonRcvRun: walking new dir %s: %s\n",
|
||||
ev.m_path.c_str(), walker.getReason().c_str()));
|
||||
LOGERR("rclMonRcvRun: walking new dir " << (ev.m_path) << ": " << (walker.getReason()) << "\n" );
|
||||
goto terminate;
|
||||
}
|
||||
if (walker.getErrCnt() > 0) {
|
||||
LOGINFO(("rclMonRcvRun: fs walker errors: %s\n",
|
||||
walker.getReason().c_str()));
|
||||
LOGINFO("rclMonRcvRun: fs walker errors: " << (walker.getReason()) << "\n" );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,7 +255,7 @@ void *rclMonRcvRun(void *q)
|
||||
|
||||
terminate:
|
||||
queue->setTerminate();
|
||||
LOGINFO(("rclMonRcvRun: monrcv thread routine returning\n"));
|
||||
LOGINFO("rclMonRcvRun: monrcv thread routine returning\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -353,7 +339,7 @@ RclFAM::RclFAM()
|
||||
: m_ok(false)
|
||||
{
|
||||
if (FAMOpen2(&m_conn, "Recoll")) {
|
||||
LOGERR(("RclFAM::RclFAM: FAMOpen2 failed, errno %d\n", errno));
|
||||
LOGERR("RclFAM::RclFAM: FAMOpen2 failed, errno " << (errno) << "\n" );
|
||||
return;
|
||||
}
|
||||
m_ok = true;
|
||||
@@ -384,7 +370,7 @@ bool RclFAM::addWatch(const string& path, bool isdir)
|
||||
// to unblock signals. SIGALRM is not used by the main thread, so at least
|
||||
// ensure that we exit after gamin gets stuck.
|
||||
if (setjmp(jbuf)) {
|
||||
LOGERR(("RclFAM::addWatch: timeout talking to FAM\n"));
|
||||
LOGERR("RclFAM::addWatch: timeout talking to FAM\n" );
|
||||
return false;
|
||||
}
|
||||
signal(SIGALRM, onalrm);
|
||||
@@ -392,12 +378,12 @@ bool RclFAM::addWatch(const string& path, bool isdir)
|
||||
FAMRequest req;
|
||||
if (isdir) {
|
||||
if (FAMMonitorDirectory(&m_conn, path.c_str(), &req, 0) != 0) {
|
||||
LOGERR(("RclFAM::addWatch: FAMMonitorDirectory failed\n"));
|
||||
LOGERR("RclFAM::addWatch: FAMMonitorDirectory failed\n" );
|
||||
goto out;
|
||||
}
|
||||
} else {
|
||||
if (FAMMonitorFile(&m_conn, path.c_str(), &req, 0) != 0) {
|
||||
LOGERR(("RclFAM::addWatch: FAMMonitorFile failed\n"));
|
||||
LOGERR("RclFAM::addWatch: FAMMonitorFile failed\n" );
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
@@ -435,7 +421,7 @@ bool RclFAM::getEvent(RclMonEvent& ev, int msecs)
|
||||
}
|
||||
int ret;
|
||||
if ((ret=select(fam_fd+1, &readfds, 0, 0, msecs >= 0 ? &timeout : 0)) < 0) {
|
||||
LOGERR(("RclFAM::getEvent: select failed, errno %d\n", errno));
|
||||
LOGERR("RclFAM::getEvent: select failed, errno " << (errno) << "\n" );
|
||||
close();
|
||||
return false;
|
||||
} else if (ret == 0) {
|
||||
@@ -462,7 +448,7 @@ bool RclFAM::getEvent(RclMonEvent& ev, int msecs)
|
||||
MONDEB(("RclFAM::getEvent: call FAMNextEvent\n"));
|
||||
FAMEvent fe;
|
||||
if (FAMNextEvent(&m_conn, &fe) < 0) {
|
||||
LOGERR(("RclFAM::getEvent: FAMNextEvent failed, errno %d\n", errno));
|
||||
LOGERR("RclFAM::getEvent: FAMNextEvent failed, errno " << (errno) << "\n" );
|
||||
close();
|
||||
return false;
|
||||
}
|
||||
@@ -511,7 +497,7 @@ bool RclFAM::getEvent(RclMonEvent& ev, int msecs)
|
||||
// Have to return something, this is different from an empty queue,
|
||||
// esp if we are trying to empty it...
|
||||
if (fe.code != FAMEndExist)
|
||||
LOGDEB(("RclFAM::getEvent: got other event %d!\n", fe.code));
|
||||
LOGDEB("RclFAM::getEvent: got other event " << (fe.code) << "!\n" );
|
||||
ev.m_etyp = RclMonEvent::RCLEVT_NONE;
|
||||
break;
|
||||
}
|
||||
@@ -532,7 +518,7 @@ public:
|
||||
: m_ok(false), m_fd(-1), m_evp(0), m_ep(0)
|
||||
{
|
||||
if ((m_fd = inotify_init()) < 0) {
|
||||
LOGERR(("RclIntf:: inotify_init failed, errno %d\n", errno));
|
||||
LOGERR("RclIntf:: inotify_init failed, errno " << (errno) << "\n" );
|
||||
return;
|
||||
}
|
||||
m_ok = true;
|
||||
@@ -616,11 +602,9 @@ bool RclIntf::addWatch(const string& path, bool)
|
||||
int wd;
|
||||
if ((wd = inotify_add_watch(m_fd, path.c_str(), mask)) < 0) {
|
||||
saved_errno = errno;
|
||||
LOGERR(("RclIntf::addWatch: inotify_add_watch failed. errno %d\n",
|
||||
saved_errno));
|
||||
LOGERR("RclIntf::addWatch: inotify_add_watch failed. errno " << (saved_errno) << "\n" );
|
||||
if (errno == ENOSPC) {
|
||||
LOGERR(("RclIntf::addWatch: ENOSPC error may mean that you need"
|
||||
"increase the inotify kernel constants. See inotify(7)\n"));
|
||||
LOGERR("RclIntf::addWatch: ENOSPC error may mean that you needincrease the inotify kernel constants. See inotify(7)\n" );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -649,7 +633,7 @@ bool RclIntf::getEvent(RclMonEvent& ev, int msecs)
|
||||
int ret;
|
||||
MONDEB(("RclIntf::getEvent: select\n"));
|
||||
if ((ret=select(m_fd + 1, &readfds, 0, 0, msecs >= 0 ? &timeout : 0)) < 0) {
|
||||
LOGERR(("RclIntf::getEvent: select failed, errno %d\n", errno));
|
||||
LOGERR("RclIntf::getEvent: select failed, errno " << (errno) << "\n" );
|
||||
close();
|
||||
return false;
|
||||
} else if (ret == 0) {
|
||||
@@ -663,8 +647,7 @@ bool RclIntf::getEvent(RclMonEvent& ev, int msecs)
|
||||
return false;
|
||||
int rret;
|
||||
if ((rret=read(m_fd, m_evbuf, sizeof(m_evbuf))) <= 0) {
|
||||
LOGERR(("RclIntf::getEvent: read failed, %d->%d errno %d\n",
|
||||
sizeof(m_evbuf), rret, errno));
|
||||
LOGERR("RclIntf::getEvent: read failed, " << (sizeof(m_evbuf)) << "->" << (rret) << " errno " << (errno) << "\n" );
|
||||
close();
|
||||
return false;
|
||||
}
|
||||
@@ -681,7 +664,7 @@ bool RclIntf::getEvent(RclMonEvent& ev, int msecs)
|
||||
|
||||
map<int,string>::const_iterator it;
|
||||
if ((it = m_idtopath.find(evp->wd)) == m_idtopath.end()) {
|
||||
LOGERR(("RclIntf::getEvent: unknown wd %d\n", evp->wd));
|
||||
LOGERR("RclIntf::getEvent: unknown wd " << (evp->wd) << "\n" );
|
||||
return true;
|
||||
}
|
||||
ev.m_path = it->second;
|
||||
@@ -721,13 +704,12 @@ bool RclIntf::getEvent(RclMonEvent& ev, int msecs)
|
||||
}
|
||||
} else if (evp->mask & (IN_IGNORED)) {
|
||||
if (!m_idtopath.erase(evp->wd)) {
|
||||
LOGDEB0(("Got IGNORE event for unknown watch\n"));
|
||||
LOGDEB0("Got IGNORE event for unknown watch\n" );
|
||||
} else {
|
||||
eraseWatchSubTree(m_idtopath, ev.m_path);
|
||||
}
|
||||
} else {
|
||||
LOGDEB(("RclIntf::getEvent: unhandled event %s 0x%x %s\n",
|
||||
event_name(evp->mask), evp->mask, ev.m_path.c_str()));
|
||||
LOGDEB("RclIntf::getEvent: unhandled event " << (event_name(evp->mask)) << " 0x" << (evp->mask) << " " << (ev.m_path) << "\n" );
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
@@ -748,8 +730,8 @@ static RclMonitor *makeMonitor()
|
||||
return new RclFAM;
|
||||
#endif
|
||||
#endif
|
||||
LOGINFO(("RclMonitor: neither Inotify nor Fam was compiled as "
|
||||
"file system change notification interface\n"));
|
||||
LOGINFO("RclMonitor: neither Inotify nor Fam was compiled as file system change notification interface\n" );
|
||||
return 0;
|
||||
}
|
||||
#endif // RCL_MONITOR
|
||||
|
||||
|
||||
+21
-27
@@ -36,7 +36,7 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include "debuglog.h"
|
||||
#include "log.h"
|
||||
#include "rclinit.h"
|
||||
#include "indexer.h"
|
||||
#include "smallut.h"
|
||||
@@ -148,7 +148,7 @@ class MyUpdater : public DbIxStatusUpdater {
|
||||
// out and the indexing would go on, not good (ie: if the user
|
||||
// logs in again, the new recollindex will fail).
|
||||
if ((op_flags & OPT_m) && !(op_flags & OPT_x) && !x11IsAlive()) {
|
||||
LOGDEB(("X11 session went away during initial indexing pass\n"));
|
||||
LOGDEB("X11 session went away during initial indexing pass\n" );
|
||||
stopindexing = true;
|
||||
return false;
|
||||
}
|
||||
@@ -166,7 +166,7 @@ static MyUpdater *updater;
|
||||
static void sigcleanup(int sig)
|
||||
{
|
||||
fprintf(stderr, "Got signal, registering stop request\n");
|
||||
LOGDEB(("Got signal, registering stop request\n"));
|
||||
LOGDEB("Got signal, registering stop request\n" );
|
||||
CancelCheck::instance().setCancel();
|
||||
stopindexing = 1;
|
||||
}
|
||||
@@ -301,7 +301,7 @@ static bool checktopdirs(RclConfig *config, vector<string>& nonexist)
|
||||
vector<string> tdl;
|
||||
if (!config->getConfParam("topdirs", &tdl)) {
|
||||
cerr << "No 'topdirs' parameter in configuration\n";
|
||||
LOGERR(("recollindex:No 'topdirs' parameter in configuration\n"));;
|
||||
LOGERR("recollindex:No 'topdirs' parameter in configuration\n" );;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -310,12 +310,10 @@ static bool checktopdirs(RclConfig *config, vector<string>& nonexist)
|
||||
if (!it->size() || !path_isabsolute(*it)) {
|
||||
if ((*it)[0] == '~') {
|
||||
cerr << "Tilde expansion failed: " << *it << endl;
|
||||
LOGERR(("recollindex: tilde expansion failed: %s\n",
|
||||
it->c_str()));
|
||||
LOGERR("recollindex: tilde expansion failed: " << *it << "\n" );
|
||||
} else {
|
||||
cerr << "Not an absolute path: " << *it << endl;
|
||||
LOGERR(("recollindex: not an absolute path: %s\n",
|
||||
it->c_str()));
|
||||
LOGERR("recollindex: not an absolute path: " << *it << "\n" );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -516,18 +514,14 @@ int main(int argc, char **argv)
|
||||
string rundir;
|
||||
config->getConfParam("idxrundir", rundir);
|
||||
if (!rundir.compare("tmp")) {
|
||||
LOGINFO(("recollindex: changing current directory to [%s]\n",
|
||||
tmplocation().c_str()));
|
||||
LOGINFO("recollindex: changing current directory to [" << (tmplocation()) << "]\n" );
|
||||
if (chdir(tmplocation().c_str()) < 0) {
|
||||
LOGERR(("chdir(%s) failed, errno %d\n",
|
||||
tmplocation().c_str(), errno));
|
||||
LOGERR("chdir(" << (tmplocation()) << ") failed, errno " << (errno) << "\n" );
|
||||
}
|
||||
} else if (!rundir.empty()) {
|
||||
LOGINFO(("recollindex: changing current directory to [%s]\n",
|
||||
rundir.c_str()));
|
||||
LOGINFO("recollindex: changing current directory to [" << (rundir) << "]\n" );
|
||||
if (chdir(rundir.c_str()) < 0) {
|
||||
LOGERR(("chdir(%s) failed, errno %d\n",
|
||||
rundir.c_str(), errno));
|
||||
LOGERR("chdir(" << (rundir) << ") failed, errno " << (errno) << "\n" );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -550,10 +544,10 @@ int main(int argc, char **argv)
|
||||
|
||||
// Log something at LOGINFO to reset the trace file. Else at level
|
||||
// 3 it's not even truncated if all docs are up to date.
|
||||
LOGINFO(("recollindex: starting up\n"));
|
||||
LOGINFO("recollindex: starting up\n" );
|
||||
#ifndef _WIN32
|
||||
if (setpriority(PRIO_PROCESS, 0, 20) != 0) {
|
||||
LOGINFO(("recollindex: can't setpriority(), errno %d\n", errno));
|
||||
LOGINFO("recollindex: can't setpriority(), errno " << (errno) << "\n" );
|
||||
}
|
||||
// Try to ionice. This does not work on all platforms
|
||||
rclIxIonice(config);
|
||||
@@ -625,11 +619,11 @@ int main(int argc, char **argv)
|
||||
Usage();
|
||||
lockorexit(&pidfile);
|
||||
if (!(op_flags&OPT_D)) {
|
||||
LOGDEB(("recollindex: daemonizing\n"));
|
||||
LOGDEB("recollindex: daemonizing\n" );
|
||||
#ifndef _WIN32
|
||||
if (daemon(0,0) != 0) {
|
||||
fprintf(stderr, "daemon() failed, errno %d\n", errno);
|
||||
LOGERR(("daemon() failed, errno %d\n", errno));
|
||||
LOGERR("daemon() failed, errno " << (errno) << "\n" );
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
@@ -640,30 +634,29 @@ int main(int argc, char **argv)
|
||||
// Not too sure if I have to redo the nice thing after daemon(),
|
||||
// can't hurt anyway (easier than testing on all platforms...)
|
||||
if (setpriority(PRIO_PROCESS, 0, 20) != 0) {
|
||||
LOGINFO(("recollindex: can't setpriority(), errno %d\n", errno));
|
||||
LOGINFO("recollindex: can't setpriority(), errno " << (errno) << "\n" );
|
||||
}
|
||||
// Try to ionice. This does not work on all platforms
|
||||
rclIxIonice(config);
|
||||
#endif
|
||||
|
||||
if (sleepsecs > 0) {
|
||||
LOGDEB(("recollindex: sleeping %d\n", sleepsecs));
|
||||
LOGDEB("recollindex: sleeping " << (sleepsecs) << "\n" );
|
||||
for (int i = 0; i < sleepsecs; i++) {
|
||||
sleep(1);
|
||||
// Check that x11 did not go away while we were sleeping.
|
||||
if (!(op_flags & OPT_x) && !x11IsAlive()) {
|
||||
LOGDEB(("X11 session went away during initial sleep period\n"));
|
||||
LOGDEB("X11 session went away during initial sleep period\n" );
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!(op_flags & OPT_n)) {
|
||||
makeIndexerOrExit(config, inPlaceReset);
|
||||
LOGDEB(("Recollindex: initial indexing pass before monitoring\n"));
|
||||
LOGDEB("Recollindex: initial indexing pass before monitoring\n" );
|
||||
if (!confindexer->index(rezero, ConfIndexer::IxTAll, indexerFlags)
|
||||
|| stopindexing) {
|
||||
LOGERR(("recollindex, initial indexing pass failed, "
|
||||
"not going into monitor mode\n"));
|
||||
LOGERR("recollindex, initial indexing pass failed, not going into monitor mode\n" );
|
||||
exit(1);
|
||||
} else {
|
||||
// Record success of indexing pass with failed files retries.
|
||||
@@ -674,7 +667,7 @@ int main(int argc, char **argv)
|
||||
deleteZ(confindexer);
|
||||
#ifndef _WIN32
|
||||
o_reexec->insertArgs(vector<string>(1, "-n"));
|
||||
LOGINFO(("recollindex: reexecuting with -n after initial full pass\n"));
|
||||
LOGINFO("recollindex: reexecuting with -n after initial full pass\n" );
|
||||
// Note that -n will be inside the reexec when we come
|
||||
// back, but the monitor will explicitely strip it before
|
||||
// starting a config change exec to ensure that we do a
|
||||
@@ -724,3 +717,4 @@ int main(int argc, char **argv)
|
||||
return !status;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,16 +25,15 @@
|
||||
#include "searchdata.h"
|
||||
#include "rclquery.h"
|
||||
#include "subtreelist.h"
|
||||
#include "debuglog.h"
|
||||
#include "log.h"
|
||||
|
||||
bool subtreelist(RclConfig *config, const string& top,
|
||||
vector<string>& paths)
|
||||
{
|
||||
LOGDEB(("subtreelist: top: [%s]\n", top.c_str()));
|
||||
LOGDEB("subtreelist: top: [" << (top) << "]\n" );
|
||||
Rcl::Db rcldb(config);
|
||||
if (!rcldb.open(Rcl::Db::DbRO)) {
|
||||
LOGERR(("subtreelist: can't open database in [%s]: %s\n",
|
||||
config->getDbDir().c_str(), rcldb.getReason().c_str()));
|
||||
LOGERR("subtreelist: can't open database in [" << (config->getDbDir()) << "]: " << (rcldb.getReason()) << "\n" );
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -129,3 +128,4 @@ int main(int argc, char **argv)
|
||||
exit(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user