After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 736350 - GDesktopAppInfo: avoid polling on missing desktop dirs
GDesktopAppInfo: avoid polling on missing desktop dirs
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on: 522314
Blocks:
 
 
Reported: 2014-09-09 18:11 UTC by Allison Karlitskaya (desrt)
Modified: 2014-09-09 20:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
apps test: add new "monitor" subcommand (1.37 KB, patch)
2014-09-09 18:11 UTC, Allison Karlitskaya (desrt)
committed Details | Review
GDesktopAppInfo: avoid inotify on missing dirs (6.03 KB, patch)
2014-09-09 18:11 UTC, Allison Karlitskaya (desrt)
committed Details | Review

Description Allison Karlitskaya (desrt) 2014-09-09 18:11:37 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.
Comment 1 Allison Karlitskaya (desrt) 2014-09-09 18:11:39 UTC
Created attachment 285766 [details] [review]
apps test: add new "monitor" subcommand

Waits until something modifies a desktop directory, then exits.
Comment 2 Allison Karlitskaya (desrt) 2014-09-09 18:11:45 UTC
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.
Comment 3 Matthias Clasen 2014-09-09 18:44:33 UTC
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
Comment 4 Matthias Clasen 2014-09-09 18:45:00 UTC
Review of attachment 285766 [details] [review]:

this is not getting used anywhere ?
Comment 5 Allison Karlitskaya (desrt) 2014-09-09 20:24:10 UTC
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.
Comment 6 Allison Karlitskaya (desrt) 2014-09-09 20:53:26 UTC
Attachment 285766 [details] pushed as 2f55c66 - apps test: add new "monitor" subcommand
Attachment 285767 [details] pushed as 3b8bc8b - GDesktopAppInfo: avoid inotify on missing dirs