GNOME Bugzilla – Bug 736350
GDesktopAppInfo: avoid polling on missing desktop dirs
Last modified: 2014-09-09 20:53:57 UTC
It's sometimes the case that /usr/local/share/applications will be missing or that XDG_DATA_DIRS will be set to include a directory that doesn't have a applications/ directory. Due to bug 522314 this means we end up polling. While we ponder how to correctly fix bug 522314 (which will be invasive and possibly involve adding new API) we should at least make it so that a casual query of a desktop file won't result in the process waking every 4 seconds thereafter.
Created attachment 285766 [details] [review] apps test: add new "monitor" subcommand Waits until something modifies a desktop directory, then exits.
Created attachment 285767 [details] [review] GDesktopAppInfo: avoid inotify on missing dirs Some desktop file directories, like /usr/local/share/applications may be missing on some systems. When we try to inotify on these directories, this will result in a every-4-seconds poll being setup which is quite bad. This is an issue that should be fixed in inotify itself but the problem is much larger there. For now, we can work around it in GDesktopAppInfo by refusing to monitor missing directories. We may get some spurious notifications of changes in the case that /usr/local/share or /usr/local/share/applications is created without actually adding desktop files, but spurious changes can already be reported in other cases, so that's OK. We won't get (user-visible) notification for a simple case of a completely unrelated file being created (however we cannot avoid the wakeup in this case due to how inotify works). That's probably pretty theoretical, though, since files in /usr don't change much and for the home directory we're likely to have at least ~/.config and ~/.local existing.
Review of attachment 285767 [details] [review]: Do I understand it correctly, that we never free DesktopFileDir structs ? I was looking for the place where alternatively_watching would be freed, but then I couldn't even find the place where path gets freed. If thats true, then this looks good
Review of attachment 285766 [details] [review]: this is not getting used anywhere ?
Review of attachment 285767 [details] [review]: ::: gio/gdesktopappinfo.c @@ +1273,3 @@ + if (dir->alternatively_watching) + { + g_free (dir->alternatively_watching); It gets freed here, in desktop_file_dir_reset, but it's true that the structs themselves are never freed -- only reset. It will be reset in the case that the directory pops into existence, at which point the "alternatively watching" mechanism won't be needed.
Attachment 285766 [details] pushed as 2f55c66 - apps test: add new "monitor" subcommand Attachment 285767 [details] pushed as 3b8bc8b - GDesktopAppInfo: avoid inotify on missing dirs