From 6537356236a617ec934ceddd69095cb4a96508ea Mon Sep 17 00:00:00 2001 From: David Hart Date: Fri, 19 Aug 2016 23:15:53 +0200 Subject: [PATCH] Make failure to remove an inotify watch a warning Apparently this can happen when a directory is deleted just before the watch is removed and it is impossible to avoid it, so just send a warning message so that the program could react to this, if necessary, but don't annoy the user with an error in this case. See #17122. --- src/unix/fswatcher_inotify.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/unix/fswatcher_inotify.cpp b/src/unix/fswatcher_inotify.cpp index 6caeb3ab66..681700d367 100644 --- a/src/unix/fswatcher_inotify.cpp +++ b/src/unix/fswatcher_inotify.cpp @@ -129,8 +129,20 @@ public: int ret = DoRemoveInotify(watch.get()); if (ret == -1) { - wxLogSysError( _("Unable to remove inotify watch") ); - return false; + // Failures can happen if a dir is deleted just before we try to + // remove the watch. I think there's a race between calling this + // code and IN_DELETE_SELF arriving. So just warn. + wxFileSystemWatcherEvent + event + ( + wxFSW_EVENT_WARNING, wxFSW_WARNING_GENERAL, + wxString::Format + ( + _("Unable to remove inotify watch %i"), + watch->GetWatchDescriptor() + ) + ); + SendEvent(event); } if (m_watchMap.erase(watch->GetWatchDescriptor()) != 1)