summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Zeuthen <davidz@redhat.com>2011-05-23 15:37:30 -0400
committerDavid Zeuthen <davidz@redhat.com>2011-05-23 15:37:30 -0400
commit510823f63256deacfcd83f91fcc82f7d30d44a43 (patch)
tree75f87b24441f4905e5ab6b17d6c32035135063f3
parent69af5b2ea2164437ec44e29750fc04179be03923 (diff)
Fix file monitoring
Apparently we're not guaranteed that the CHANGES_DONE_HINT is emitted. Signed-off-by: David Zeuthen <davidz@redhat.com>
-rw-r--r--src/daemon/goadaemon.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/daemon/goadaemon.c b/src/daemon/goadaemon.c
index cfa1638..738bea2 100644
--- a/src/daemon/goadaemon.c
+++ b/src/daemon/goadaemon.c
@@ -53,6 +53,8 @@ struct _GoaDaemon
GoaManager *manager;
NotifyNotification *notification;
+
+ guint config_timeout_id;
};
typedef struct
@@ -102,6 +104,11 @@ goa_daemon_finalize (GObject *object)
{
GoaDaemon *daemon = GOA_DAEMON (object);
+ if (daemon->config_timeout_id != 0)
+ {
+ g_source_remove (daemon->config_timeout_id);
+ }
+
if (daemon->notification != NULL)
{
g_signal_handlers_disconnect_by_func (daemon->notification,
@@ -160,6 +167,18 @@ create_monitor (const gchar *path, gboolean is_dir)
return monitor;
}
+static gboolean
+on_config_file_monitor_timeout (gpointer user_data)
+{
+ GoaDaemon *daemon = GOA_DAEMON (user_data);
+
+ daemon->config_timeout_id = 0;
+ goa_info ("Reloading configuration files\n");
+ goa_daemon_reload_configuration (daemon);
+
+ return FALSE;
+}
+
static void
on_file_monitor_changed (GFileMonitor *monitor,
GFile *file,
@@ -168,10 +187,10 @@ on_file_monitor_changed (GFileMonitor *monitor,
gpointer user_data)
{
GoaDaemon *daemon = GOA_DAEMON (user_data);
- if (event_type == G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT)
+
+ if (daemon->config_timeout_id == 0)
{
- g_print ("Reloading configuration files\n");
- goa_daemon_reload_configuration (daemon);
+ daemon->config_timeout_id = g_timeout_add (200, on_config_file_monitor_timeout, daemon);
}
}