try to be more responsive to interruptions

This commit is contained in:
dockes 2006-12-21 10:08:07 +00:00
parent 4bce91b3d6
commit a7e9ff5fd6

View File

@ -2,7 +2,7 @@
#ifdef RCL_MONITOR #ifdef RCL_MONITOR
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: rclmonprc.cpp,v 1.7 2006-11-07 16:51:45 dockes Exp $ (C) 2006 J.F.Dockes"; static char rcsid[] = "@(#$Id: rclmonprc.cpp,v 1.8 2006-12-21 10:08:07 dockes Exp $ (C) 2006 J.F.Dockes";
#endif #endif
/* /*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -272,12 +272,11 @@ bool startMonitor(RclConfig *conf, bool nofork)
} }
LOGDEB(("start_monitoring: entering main loop\n")); LOGDEB(("start_monitoring: entering main loop\n"));
bool timedout; bool timedout;
time_t lastauxtime = time(0);
bool didsomething = false; bool didsomething = false;
// We set a timeout of 10mn. If we do timeout, and there have been some // Set a relatively short timeout for better monitoring of exit requests
// indexing activity since the last such operation, we'll update the while (rclEQ.wait(2, &timedout)) {
// auxiliary data (stemming and spelling)
while (rclEQ.wait(10 * 60, &timedout)) {
// Queue is locked. // Queue is locked.
if (!rclEQ.ok()) if (!rclEQ.ok())
@ -317,16 +316,12 @@ bool startMonitor(RclConfig *conf, bool nofork)
didsomething = true; didsomething = true;
} }
if (timedout) { // Recreate the auxiliary dbs every hour.
MONDEB(("Monitor: queue wait timed out\n")); if (time(0) - lastauxtime > 60 *60) {
// Timed out. there must not be much activity around here. lastauxtime = time(0);
// If anything was modified, process the end-of-indexing didsomething = false;
// tasks: stemming and spelling database creations. if (!createAuxDbs(conf))
if (didsomething) { break;
didsomething = false;
if (!createAuxDbs(conf))
break;
}
} }
// Lock queue before waiting again // Lock queue before waiting again