monitor: perform doc deletes before updates. Start processing the queue as soon as it s big enough even if interval not expired

This commit is contained in:
Jean-Francois Dockes 2011-09-03 10:39:11 +02:00
parent b2872935bb
commit 5d0a22f5c3

View File

@ -497,19 +497,14 @@ bool startMonitor(RclConfig *conf, int opts)
// Unlock queue before processing lists
rclEQ.unlock();
// Process. We don't do this everytime but let the lists accumulate
// a little, this saves processing.
// Process. We don't do this every time but let the lists accumulate
// a little, this saves processing. Start at once if list is big.
time_t now = time(0);
if (now - lastixtime > ixinterval) {
if ((now - lastixtime > ixinterval) ||
(deleted.size() + modified.size() > 20)) {
lastixtime = now;
if (!modified.empty()) {
modified.sort();
modified.unique();
if (!indexfiles(conf, modified))
break;
modified.clear();
didsomething = true;
}
// Used to do the modified list first, but it does seem
// smarter to make room first...
if (!deleted.empty()) {
deleted.sort();
deleted.unique();
@ -518,6 +513,14 @@ bool startMonitor(RclConfig *conf, int opts)
deleted.clear();
didsomething = true;
}
if (!modified.empty()) {
modified.sort();
modified.unique();
if (!indexfiles(conf, modified))
break;
modified.clear();
didsomething = true;
}
}
// Recreate the auxiliary dbs every hour at most.