monitor: accumulate mods during 30S before indexing
This commit is contained in:
parent
061aa959c6
commit
1406bca35b
@ -294,7 +294,13 @@ bool startMonitor(RclConfig *conf, int opts)
|
|||||||
LOGDEB(("start_monitoring: entering main loop\n"));
|
LOGDEB(("start_monitoring: entering main loop\n"));
|
||||||
bool timedout;
|
bool timedout;
|
||||||
time_t lastauxtime = time(0);
|
time_t lastauxtime = time(0);
|
||||||
|
time_t lastixtime = lastauxtime;
|
||||||
bool didsomething = false;
|
bool didsomething = false;
|
||||||
|
const int auxinterval = 60 *60;
|
||||||
|
const int ixinterval = 30;
|
||||||
|
|
||||||
|
list<string> modified;
|
||||||
|
list<string> deleted;
|
||||||
|
|
||||||
// Set a relatively short timeout for better monitoring of exit requests
|
// Set a relatively short timeout for better monitoring of exit requests
|
||||||
while (rclEQ.wait(2, &timedout)) {
|
while (rclEQ.wait(2, &timedout)) {
|
||||||
@ -310,9 +316,6 @@ bool startMonitor(RclConfig *conf, int opts)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
list<string> modified;
|
|
||||||
list<string> deleted;
|
|
||||||
|
|
||||||
// Process event queue
|
// Process event queue
|
||||||
while (!rclEQ.empty()) {
|
while (!rclEQ.empty()) {
|
||||||
// Retrieve event
|
// Retrieve event
|
||||||
@ -333,20 +336,30 @@ bool startMonitor(RclConfig *conf, int opts)
|
|||||||
// Unlock queue before processing lists
|
// Unlock queue before processing lists
|
||||||
rclEQ.unlock();
|
rclEQ.unlock();
|
||||||
|
|
||||||
// Process
|
// Process. We don't do this everytime but let the lists accumulate
|
||||||
if (!modified.empty()) {
|
// a little, this saves processing.
|
||||||
if (!indexfiles(conf, modified))
|
time_t now = time(0);
|
||||||
break;
|
if (now - lastixtime > ixinterval) {
|
||||||
didsomething = true;
|
lastixtime = now;
|
||||||
}
|
if (!modified.empty()) {
|
||||||
if (!deleted.empty()) {
|
modified.sort();
|
||||||
if (!purgefiles(conf, deleted))
|
modified.unique();
|
||||||
break;
|
if (!indexfiles(conf, modified))
|
||||||
didsomething = true;
|
break;
|
||||||
}
|
modified.clear();
|
||||||
|
didsomething = true;
|
||||||
|
}
|
||||||
|
if (!deleted.empty()) {
|
||||||
|
deleted.sort();
|
||||||
|
deleted.unique();
|
||||||
|
if (!purgefiles(conf, deleted))
|
||||||
|
break;
|
||||||
|
deleted.clear();
|
||||||
|
didsomething = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Recreate the auxiliary dbs every hour at most.
|
// Recreate the auxiliary dbs every hour at most.
|
||||||
const int auxinterval = 60 *60;
|
|
||||||
if (didsomething && time(0) - lastauxtime > auxinterval) {
|
if (didsomething && time(0) - lastauxtime > auxinterval) {
|
||||||
lastauxtime = time(0);
|
lastauxtime = time(0);
|
||||||
didsomething = false;
|
didsomething = false;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user