From f6f0959db2d4a7fe64d8743bd55aafbff39de0c2 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Fri, 14 Mar 2008 11:03:32 +0000 Subject: [PATCH] Shut down fam (including removing fam GSource) when module is unloaded 2008-03-14 Alexander Larsson * fam/fam-helper.[ch]: * fam/fam-module.c: Shut down fam (including removing fam GSource) when module is unloaded (#521513) Patch from Joe Marcus Clarke svn path=/branches/glib-2-16/; revision=6707 --- gio/ChangeLog | 8 ++++++++ gio/fam/fam-helper.c | 16 ++++++++++++++++ gio/fam/fam-helper.h | 1 + gio/fam/fam-module.c | 2 ++ 4 files changed, 27 insertions(+) diff --git a/gio/ChangeLog b/gio/ChangeLog index b40fa6b96..45e8dfe16 100644 --- a/gio/ChangeLog +++ b/gio/ChangeLog @@ -1,3 +1,11 @@ +2008-03-14 Alexander Larsson + + * fam/fam-helper.[ch]: + * fam/fam-module.c: + Shut down fam (including removing fam GSource) when + module is unloaded (#521513) + Patch from Joe Marcus Clarke + 2008-03-14 Alexander Larsson * glocalfile.c: diff --git a/gio/fam/fam-helper.c b/gio/fam/fam-helper.c index c6b2c5f38..164e3ab21 100644 --- a/gio/fam/fam-helper.c +++ b/gio/fam/fam-helper.c @@ -181,6 +181,22 @@ _fam_sub_startup (void) return TRUE; } +void +_fam_sub_shutdown (void) +{ + G_LOCK (fam_connection); + + if (fam_connection != NULL) { + FAMClose (fam_connection); + g_free (fam_connection); + g_source_remove (fam_watch_id); + fam_watch_id = 0; + fam_connection = NULL; + } + + G_UNLOCK (fam_connection); +} + fam_sub* _fam_sub_add (const gchar* pathname, gboolean directory, diff --git a/gio/fam/fam-helper.h b/gio/fam/fam-helper.h index e8acbfeff..05e67d11f 100644 --- a/gio/fam/fam-helper.h +++ b/gio/fam/fam-helper.h @@ -28,6 +28,7 @@ typedef struct _fam_sub fam_sub; gboolean _fam_sub_startup (void); +void _fam_sub_shutdown (void); fam_sub* _fam_sub_add (const gchar* pathname, gboolean directory, gpointer user_data); diff --git a/gio/fam/fam-module.c b/gio/fam/fam-module.c index d7b9cfcae..70e8dea22 100644 --- a/gio/fam/fam-module.c +++ b/gio/fam/fam-module.c @@ -26,6 +26,7 @@ #include "giomodule.h" #include "gfamdirectorymonitor.h" #include "gfamfilemonitor.h" +#include "fam-helper.h" void g_io_module_load (GIOModule *module) @@ -37,5 +38,6 @@ g_io_module_load (GIOModule *module) void g_io_module_unload (GIOModule *module) { + _fam_sub_shutdown (); }