dont terminate monitor for permission-related addwatch error

This commit is contained in:
Jean-Francois Dockes 2012-08-14 08:15:49 +02:00
parent 6331415f7e
commit 83ea60484c

View File

@ -33,17 +33,27 @@
* to FAM or inotify and place events on the event queue.
*/
/** A small virtual interface for monitors. Probably suitable to let
either of fam/gamin or raw imonitor hide behind */
/** A small virtual interface for monitors. Lets
* either fam/gamin or raw imonitor hide behind
*/
class RclMonitor {
public:
RclMonitor(){}
virtual ~RclMonitor() {}
RclMonitor()
: saved_errno(0)
{
}
virtual ~RclMonitor()
{
}
virtual bool addWatch(const string& path, bool isDir) = 0;
virtual bool getEvent(RclMonEvent& ev, int msecs = -1) = 0;
virtual bool ok() const = 0;
// Does this monitor generate 'exist' events at startup?
virtual bool generatesExist() const = 0;
// Save significant errno after monitor calls
int saved_errno;
};
// Monitor factory. We only have one compiled-in kind at a time, no
@ -94,8 +104,14 @@ public:
break;
}
}
if (!m_mon || !m_mon->ok() || !m_mon->addWatch(fn, true))
if (!m_mon || !m_mon->ok())
return FsTreeWalker::FtwError;
// We do nothing special if addWatch fails for a reasonable reason
if (!m_mon->addWatch(fn, true)) {
if (m_mon->saved_errno != EACCES &&
m_mon->saved_errno != ENOENT)
return FsTreeWalker::FtwError;
}
} else if (!m_mon->generatesExist() &&
flg == FsTreeWalker::FtwRegular) {
// Have to synthetize events for regular files existence
@ -198,7 +214,8 @@ void *rclMonRcvRun(void *q)
beaglequeuedir = path_tildexpand("~/.beagle/ToIndex/");
if (!mon->addWatch(beaglequeuedir, true)) {
LOGERR(("rclMonRcvRun: addwatch (beaglequeuedit) failed\n"));
goto terminate;
if (mon->saved_errno != EACCES && mon->saved_errno != ENOENT)
goto terminate;
}
}
}
@ -593,7 +610,9 @@ bool RclIntf::addWatch(const string& path, bool)
;
int wd;
if ((wd = inotify_add_watch(m_fd, path.c_str(), mask)) < 0) {
LOGERR(("RclIntf::addWatch: inotify_add_watch failed\n"));
saved_errno = errno;
LOGERR(("RclIntf::addWatch: inotify_add_watch failed. errno %d\n",
saved_errno));
return false;
}
m_idtopath[wd] = path;