real time index: dont generate events for skipped files. They would have been filtered later on, but this avoids repeatedly awaking the main thread and opening/closing the index because of events on ever changing files like the infamous .xsession-errors

This commit is contained in:
Jean-Francois Dockes 2012-03-06 07:42:40 +01:00
parent d982f5dfb9
commit 7ce1a5f2e4

View File

@ -50,10 +50,14 @@ public:
// need for a 'kind' parameter // need for a 'kind' parameter
static RclMonitor *makeMonitor(); static RclMonitor *makeMonitor();
/** This class is a callback for the file system tree walker /**
class. The callback method alternatively creates the directory * Create directory watches during the initial file system tree walk.
watches and flushes the event queue (to avoid a possible overflow *
while we create the watches)*/ * This class is a callback for the file system tree walker
* class. The callback method alternatively creates the directory
* watches and flushes the event queue (to avoid a possible overflow
* while we create the watches)
*/
class WalkCB : public FsTreeWalkerCB { class WalkCB : public FsTreeWalkerCB {
public: public:
WalkCB(RclConfig *conf, RclMonitor *mon, RclMonEventQueue *queue, WalkCB(RclConfig *conf, RclMonitor *mon, RclMonEventQueue *queue,
@ -209,6 +213,15 @@ void *rclMonRcvRun(void *q)
// write to the select fd, with no effect). So set a // write to the select fd, with no effect). So set a
// timeout so that an intr will be detected // timeout so that an intr will be detected
if (mon->getEvent(ev, 2000)) { if (mon->getEvent(ev, 2000)) {
// Don't push events for skipped files. This would get
// filtered on the processing side anyway, but causes
// unnecessary wakeups and messages
lconfig.setKeyDir(path_getfather(ev.m_path));
walker.setSkippedNames(lconfig.getSkippedNames());
if (walker.inSkippedNames(path_getsimple(ev.m_path)) ||
walker.inSkippedPaths(ev.m_path))
continue;
if (ev.m_etyp == RclMonEvent::RCLEVT_DIRCREATE) { if (ev.m_etyp == RclMonEvent::RCLEVT_DIRCREATE) {
// Recursive addwatch: there may already be stuff // Recursive addwatch: there may already be stuff
// inside this directory. Ie: files were quickly // inside this directory. Ie: files were quickly
@ -217,19 +230,16 @@ void *rclMonRcvRun(void *q)
// it seems that fam/gamin is doing the job for us so // it seems that fam/gamin is doing the job for us so
// that we are generating double events here (no big // that we are generating double events here (no big
// deal as prc will sort/merge). // deal as prc will sort/merge).
if (!walker.inSkippedNames(path_getsimple(ev.m_path)) && LOGDEB(("rclMonRcvRun: walking new dir %s\n",
!walker.inSkippedPaths(ev.m_path)) { ev.m_path.c_str()));
LOGDEB(("rclMonRcvRun: walking new dir %s\n", if (walker.walk(ev.m_path, walkcb) != FsTreeWalker::FtwOk) {
ev.m_path.c_str())); LOGERR(("rclMonRcvRun: walking new dir %s: %s\n",
if (walker.walk(ev.m_path, walkcb) != FsTreeWalker::FtwOk) { ev.m_path.c_str(), walker.getReason().c_str()));
LOGERR(("rclMonRcvRun: walking new dir %s: %s\n", goto terminate;
ev.m_path.c_str(), walker.getReason().c_str())); }
goto terminate; if (walker.getErrCnt() > 0) {
} LOGINFO(("rclMonRcvRun: fs walker errors: %s\n",
if (walker.getErrCnt() > 0) { walker.getReason().c_str()));
LOGINFO(("rclMonRcvRun: fs walker errors: %s\n",
walker.getReason().c_str()));
}
} }
} }