]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
DVR inotify: fix fundamental error when inotify filename is re-registered
authorJaroslav Kysela <perex@perex.cz>
Wed, 21 Oct 2015 17:22:15 +0000 (19:22 +0200)
committerJaroslav Kysela <perex@perex.cz>
Wed, 21 Oct 2015 17:22:15 +0000 (19:22 +0200)
src/dvr/dvr.h
src/dvr/dvr_inotify.c

index af047b6b3cb6a3522f9441cca0f6926510a6c6d6..2f638e278818825e80960337cb647867272b09b0 100644 (file)
@@ -685,6 +685,7 @@ void dvr_inotify_init ( void );
 void dvr_inotify_done ( void );
 void dvr_inotify_add  ( dvr_entry_t *de );
 void dvr_inotify_del  ( dvr_entry_t *de );
+int  dvr_inotify_count( void );
 
 /**
  * Cutpoints support
index 472d292b5f32cb1c1661ecbecea207c1eda3a57d..a20792bdb3b863b3db6079f02bb964d82e526cbb 100644 (file)
@@ -56,6 +56,7 @@ static int _str_cmp ( void *a, void *b )
   return strcmp(((dvr_inotify_entry_t*)a)->path, ((dvr_inotify_entry_t*)b)->path);
 }
 
+
 /**
  * Initialise threads
  */
@@ -107,12 +108,13 @@ void dvr_inotify_add ( dvr_entry_t *de )
   dvr_inotify_entry_skel->path = dirname(path);
   
   e = RB_INSERT_SORTED(&_inot_tree, dvr_inotify_entry_skel, link, _str_cmp);
-  if (!e) {
-    e       = dvr_inotify_entry_skel;
-    SKEL_USED(dvr_inotify_entry_skel);
-    e->path = strdup(e->path);
-    e->fd   = inotify_add_watch(_inot_fd, e->path, EVENT_MASK);
-  }
+  if (e)
+    return;
+
+  e       = dvr_inotify_entry_skel;
+  SKEL_USED(dvr_inotify_entry_skel);
+  e->path = strdup(e->path);
+  e->fd   = inotify_add_watch(_inot_fd, e->path, EVENT_MASK);
 
   LIST_INSERT_HEAD(&e->entries, de, de_inotify_link);
 
@@ -151,6 +153,21 @@ void dvr_inotify_del ( dvr_entry_t *de )
   }
 }
 
+/*
+ * return count of registered entries (for debugging)
+ */
+int dvr_inotify_count ( void )
+{
+  dvr_entry_t *det = NULL;
+  dvr_inotify_entry_t *e;
+  int count = 0;
+  lock_assert(&global_lock);
+  RB_FOREACH(e, &_inot_tree, link)
+    LIST_FOREACH(det, &e->entries, de_inotify_link)
+      count++;
+  return count;
+}
+
 /*
  * Find inotify entry
  */