Skip to content

Commit

Permalink
Attempt to mitigate lookups on unexistant Watch objects triggered
Browse files Browse the repository at this point in the history
in presently not well understood contexts. These faulty? events
are currently skipped but should be dumped into debug traces.
  • Loading branch information
seb-m committed Jan 13, 2010
1 parent 0aad346 commit c3cdeba
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions python2/pyinotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,13 @@ def process_default(self, raw_event, to_append=None):
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
Expand Down Expand Up @@ -1122,6 +1129,8 @@ def process_events(self):
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:
Expand Down
9 changes: 9 additions & 0 deletions python3/pyinotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,13 @@ def process_default(self, raw_event, to_append=None):
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
Expand Down Expand Up @@ -1085,6 +1092,8 @@ def process_events(self):
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:
Expand Down

0 comments on commit c3cdeba

Please sign in to comment.