Hi,
i took a look at the patch by Anssi Hannula and found it changing the interface
of inotify_helper, then i wrote it without changing the interface.
No one likes deadlocks.
Karl
--- gamin-0.1.10/server/inotify-helper.c 2008-11-12 21:45:28.000000000 +0100
+++ gamin-0.1.10.b/server/inotify-helper.c 2012-05-06 18:03:33.000000000 +0200
@@ -124,12 +124,10 @@
/**
* Cancels a subscription which was being monitored.
*/
-gboolean
-ih_sub_cancel (ih_sub_t * sub)
-{
- G_LOCK(inotify_lock);
-
+static void
+ih_sub_cancel_unsafe (ih_sub_t * sub)
+{
if (!sub->cancelled)
{
IH_W("cancelling %s\n", sub->pathname);
@@ -139,7 +137,15 @@
ip_stop_watching (sub);
sub_list = g_list_remove (sub_list, sub);
}
+}
+gboolean
+ih_sub_cancel (ih_sub_t * sub)
+{
+ G_LOCK(inotify_lock);
+
+ ih_sub_cancel_unsafe(sub);
+
G_UNLOCK(inotify_lock);
return TRUE;
}
@@ -159,7 +165,7 @@
if (f(sub, callerdata))
{
- ih_sub_cancel (sub); /* Removes sub from sub_list */
+ ih_sub_cancel_unsafe (sub); /* Removes sub from sub_list */
if (free)
ih_sub_free (sub);
}