glocalfilemonitor: Fallback to poll file monitor for NFS

GLib currently tries to use FAM volume monitor for monitoring files
within home on NFS. If FAM support is not available, it fallbacks by
default to GInotifyFileMonitor. I think we should fallback to
GPollFileMonitor instead, because inotify is not reliable on NFS,
which may cause issues for dconf. With this patch, it should be safe to
not build libgiofam and still be sure that dconf works properly if home
is mounted on NFS. I think this might be a first step to remove FAM
support from GLib completely, because gamin is buggy and dead for
several years already. Gamin just polls files on NFS anyway. This
change applies on files only, because GPollFileMonitor seems doesn't
support dirs, however it should be enough for dconf. The other
drawback is that one can't set poll timeout currently. Just a note
that this can still be overwritten by GIO_USE_FILE_MONITOR.
This commit is contained in:
Ondrej Holy 2018-06-15 14:29:30 +02:00
parent 3126f73c80
commit 3edc50498f

View File

@ -832,6 +832,7 @@ static void g_local_file_monitor_class_init (GLocalFileMonitorClass *class)
static GLocalFileMonitor *
g_local_file_monitor_new (gboolean is_remote_fs,
gboolean is_directory,
GError **error)
{
GType type = G_TYPE_INVALID;
@ -841,7 +842,8 @@ g_local_file_monitor_new (gboolean is_remote_fs,
"GIO_USE_FILE_MONITOR",
G_STRUCT_OFFSET (GLocalFileMonitorClass, is_supported));
if (type == G_TYPE_INVALID)
/* Fallback rather to poll file monitor for remote files, see gfile.c. */
if (type == G_TYPE_INVALID && (!is_remote_fs || is_directory))
type = _g_io_module_get_default_type (G_LOCAL_FILE_MONITOR_EXTENSION_POINT_NAME,
"GIO_USE_FILE_MONITOR",
G_STRUCT_OFFSET (GLocalFileMonitorClass, is_supported));
@ -867,7 +869,7 @@ g_local_file_monitor_new_for_path (const gchar *pathname,
is_remote_fs = g_local_file_is_remote (pathname);
monitor = g_local_file_monitor_new (is_remote_fs, error);
monitor = g_local_file_monitor_new (is_remote_fs, is_directory, error);
if (monitor)
g_local_file_monitor_start (monitor, pathname, is_directory, flags, g_main_context_get_thread_default ());
@ -888,7 +890,7 @@ g_local_file_monitor_new_in_worker (const gchar *pathname,
is_remote_fs = g_local_file_is_remote (pathname);
monitor = g_local_file_monitor_new (is_remote_fs, error);
monitor = g_local_file_monitor_new (is_remote_fs, is_directory, error);
if (monitor)
{