]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
dvr inotify: fixes for the previous IN_MOVED_TO change
authorJaroslav Kysela <perex@perex.cz>
Mon, 3 Sep 2018 13:32:39 +0000 (15:32 +0200)
committerJaroslav Kysela <perex@perex.cz>
Mon, 3 Sep 2018 13:33:18 +0000 (15:33 +0200)
src/dvr/dvr_inotify.c
src/tvhlog.c
src/tvhlog.h

index a8db57c09fee1490291a5411bf3251767da7fec4..038e3c09409271dda6b9f7b3333d662d65b3cf96 100644 (file)
@@ -31,9 +31,9 @@
 #include "htsp_server.h"
 
 /* inotify limits */
-#define EVENT_SIZE    ( sizeof (struct inotify_event) )
-#define EVENT_BUF_LEN ( 10 * ( EVENT_SIZE + 16 ) )
-#define EVENT_MASK    IN_DELETE     | IN_DELETE_SELF |\
+#define EVENT_SIZE    (sizeof(struct inotify_event))
+#define EVENT_BUF_LEN (5 * EVENT_SIZE + NAME_MAX)
+#define EVENT_MASK    IN_DELETE    | IN_DELETE_SELF | \
                       IN_MOVE_SELF | IN_MOVED_FROM | IN_MOVED_TO
                       
 static int                         _inot_fd;
@@ -378,11 +378,10 @@ void* _dvr_inotify_thread ( void *p )
   const char *from;
   int fromfd;
   int cookie;
-  char from_prev[50];
-  int fromfd_prev =0;
-  int cookie_prev =0;
-
-  from_prev[0] = '\0';
+  struct inotify_event *ev;
+  char from_prev[NAME_MAX + 1] = "";
+  int fromfd_prev = 0;
+  int cookie_prev = 0;
 
   while (tvheadend_is_running()) {
 
@@ -400,9 +399,9 @@ void* _dvr_inotify_thread ( void *p )
 
     /* Process */
     pthread_mutex_lock(&global_lock);
-    while ( i < len ) {
-      struct inotify_event *ev = (struct inotify_event*)&buf[i];
-    tvhdebug(LS_DVR, "inotify: i= %d   len= %d   ", i, len);
+    while (i < len) {
+      ev = (struct inotify_event *)&buf[i];
+      tvhtrace(LS_DVR_INOTIFY, "i=%d len=%d name=%s", i, len, ev->name);
       i += EVENT_SIZE + ev->len;
       if (i > len)
         break;
@@ -412,12 +411,12 @@ void* _dvr_inotify_thread ( void *p )
         from   = ev->name;
         fromfd = ev->wd;
         cookie = ev->cookie;
-      tvhdebug(LS_DVR, "inotify: i= %d   len= %d   from = %s   cookie = %d ", i, len, from, cookie);
+        tvhtrace(LS_DVR_INOTIFY, "i=%d len=%d from=%s cookie=%d ", i, len, from, cookie);
         continue;
 
       } else if (ev->mask & IN_MOVED_TO) {
-    tvhdebug(LS_DVR, "inotify: i= %d   len= %d    to_cookie= %d   from_cookie = %d   cookie_prev = %d", i, len, ev->cookie,cookie,cookie_prev);
-          if ( from && ev->cookie == cookie) {
+        tvhtrace(LS_DVR_INOTIFY, "i=%d len=%d to_cookie=%d from_cookie=%d cookie_prev=%d", i, len, ev->cookie, cookie, cookie_prev);
+          if (from && ev->cookie == cookie) {
             _dvr_inotify_moved(fromfd, from, ev->name, ev->wd);
             from = NULL;
            cookie = 0;
@@ -439,26 +438,19 @@ void* _dvr_inotify_thread ( void *p )
       } else if (ev->mask & IN_DELETE_SELF) {
         _dvr_inotify_delete_all(ev->wd);
       }
-/*
-      if (from) {
-        _dvr_inotify_moved(fromfd, from, NULL, -1);
-        from   = NULL;
-        cookie = 0;
-      }
-*/
     }
-    //  if still old "from", assume matching "to" is not coming
+    // if still old "from", assume matching "to" is not coming
     if (from_prev[0] != '\0') {
       _dvr_inotify_moved(fromfd_prev, from_prev, NULL, -1);
       from_prev[0] = '\0';
       cookie_prev = 0;
     }
-    //  if unmatched "from", save in case matching "to" is coming in next read
+    // if unmatched "from", save in case matching "to" is coming in next read
     if (from) {
-      strcpy ( from_prev, from);
+      strcpy(from_prev, from);
       fromfd_prev = fromfd;
       cookie_prev = cookie;
-      tvhdebug(LS_DVR, "inotify: i= %d   len= %d      cookie_prev = %d   from_prev = %s  fd = %d   END OF READ", i, len, cookie_prev, from_prev, fromfd_prev);
+      tvhdebug(LS_DVR_INOTIFY, "i=%d len=%d cookie_prev=%d from_prev=%s fd=%d EOR", i, len, cookie_prev, from_prev, fromfd_prev);
     }
     pthread_mutex_unlock(&global_lock);
   }
index 1c97ffe5537918993336214ee47869cc84046c11..f0838458ef4122bd1c50982df5100120becabff0 100644 (file)
@@ -141,6 +141,7 @@ tvhlog_subsys_t tvhlog_subsystems[] = {
   [LS_CCCAM]         = { "cccam",         N_("CWC CCCam Client") },
   [LS_DVBCAM]        = { "dvbcam",        N_("DVB CAM Client") },
   [LS_DVR]           = { "dvr",           N_("Digital Video Recorder") },
+  [LS_DVR_INOTIFY]   = { "dvr-inotify",   N_("DVR Inotify") },
   [LS_EPG]           = { "epg",           N_("Electronic Program Guide") },
   [LS_EPGDB]         = { "epgdb",         N_("EPG Database") },
   [LS_EPGGRAB]       = { "epggrab",       N_("EPG Grabber") },
index b12184a92540112ac6d13df9fe8589226354c134..f6b20b32922bebb01fdaf3fd92d0f922dc5b7a15 100644 (file)
@@ -165,6 +165,7 @@ enum {
   LS_CCCAM,
   LS_DVBCAM,
   LS_DVR,
+  LS_DVR_INOTIFY,
   LS_EPG,
   LS_EPGDB,
   LS_EPGGRAB,