summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Martini <seb@dbzteam.org>2010-01-13 19:13:39 +0100
committerSebastien Martini <seb@dbzteam.org>2010-01-13 19:13:39 +0100
commitc3cdeba1d668eb2f3c3fed3e1c30cbb1235e9196 (patch)
tree7fd64fc294061707212ee50e4dbdea6358448c31
parent0aad346a2d6cd8c4b4197c54a28f9acbdf0a0eff (diff)
downloadpyinotify-c3cdeba1d668eb2f3c3fed3e1c30cbb1235e9196.tar.gz
Attempt to mitigate lookups on unexistant Watch objects triggered
in presently not well understood contexts. These faulty? events are currently skipped but should be dumped into debug traces.
-rwxr-xr-xpython2/pyinotify.py9
-rwxr-xr-xpython3/pyinotify.py9
2 files changed, 18 insertions, 0 deletions
diff --git a/python2/pyinotify.py b/python2/pyinotify.py
index c80358e..e2a50ba 100755
--- a/python2/pyinotify.py
+++ b/python2/pyinotify.py
@@ -730,6 +730,13 @@ class _SysProcessEvent(_ProcessEvent):
IN_OPEN, IN_DELETE, IN_DELETE_SELF, IN_UNMOUNT.
"""
watch_ = self._watch_manager.get_watch(raw_event.wd)
+ if watch_ is None:
+ # Not really sure how we ended up here, nor how we should
+ # handle these types of events and if it is appropriate to
+ # completly skip them or not (like we are doing here).
+ log.debug("Unable to retrieve Watch object associated to event %s",
+ repr(raw_event))
+ return
if raw_event.mask & (IN_DELETE_SELF | IN_MOVE_SELF):
# Unfornulately this information is not provided by the kernel
dir_ = watch_.dir
@@ -1122,6 +1129,8 @@ class Notifier:
raw_event = self._eventq.popleft() # pop next event
watch_ = self._watch_manager.get_watch(raw_event.wd)
revent = self._sys_proc_fun(raw_event) # system processings
+ if revent is None:
+ continue
if watch_ and watch_.proc_fun:
watch_.proc_fun(revent) # user processings
else:
diff --git a/python3/pyinotify.py b/python3/pyinotify.py
index 85f15bd..3aa9213 100755
--- a/python3/pyinotify.py
+++ b/python3/pyinotify.py
@@ -694,6 +694,13 @@ class _SysProcessEvent(_ProcessEvent):
IN_OPEN, IN_DELETE, IN_DELETE_SELF, IN_UNMOUNT.
"""
watch_ = self._watch_manager.get_watch(raw_event.wd)
+ if watch_ is None:
+ # Not really sure how we ended up here, nor how we should
+ # handle these types of events and if it is appropriate to
+ # completly skip them or not (like we are doing here).
+ log.debug("Unable to retrieve Watch object associated to event %s",
+ repr(raw_event))
+ return
if raw_event.mask & (IN_DELETE_SELF | IN_MOVE_SELF):
# Unfornulately this information is not provided by the kernel
dir_ = watch_.dir
@@ -1085,6 +1092,8 @@ class Notifier:
raw_event = self._eventq.popleft() # pop next event
watch_ = self._watch_manager.get_watch(raw_event.wd)
revent = self._sys_proc_fun(raw_event) # system processings
+ if revent is None:
+ continue
if watch_ and watch_.proc_fun:
watch_.proc_fun(revent) # user processings
else: