]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
dvr: stop inotify code asserting, output error instead.
authorAdam Sutton <dev@adamsutton.me.uk>
Sat, 19 Jan 2013 19:48:47 +0000 (19:48 +0000)
committerAdam Sutton <dev@adamsutton.me.uk>
Sat, 19 Jan 2013 19:49:20 +0000 (19:49 +0000)
src/dvr/dvr_inotify.c

index 22c6d22b1da0be98907316f1659da888a73686c5..7d6f177c8b86d22a1c19e8736616d1db53932c69 100644 (file)
@@ -60,6 +60,11 @@ void dvr_inotify_init ( void )
   pthread_t tid;
 
   _inot_fd = inotify_init();
+  if (_inot_fd == -1) {
+    tvhlog(LOG_ERR, "dvr", "failed to initialise inotify (err=%s)",
+           strerror(errno));
+    return;
+  }
 
   pthread_create(&tid, NULL, _dvr_inotify_thread, NULL);
 }
@@ -74,6 +79,9 @@ void dvr_inotify_add ( dvr_entry_t *de )
   char *path;
   struct stat st;
 
+  if (_inot_fd == -1)
+    return;
+
   if (!de->de_filename || stat(de->de_filename, &st))
     return;
 
@@ -92,7 +100,13 @@ void dvr_inotify_add ( dvr_entry_t *de )
     skel    = NULL;
     e->path = strdup(e->path);
     e->fd   = inotify_add_watch(_inot_fd, e->path, EVENT_MASK);
-    assert(e->fd != -1);
+    if (e->fd == -1) {
+      tvhlog(LOG_ERR, "dvr", "failed to add inotify watch to %s (err=%s)",
+             e->path, strerror(errno));
+      free(path);
+      dvr_inotify_del(de);
+      return;
+    }
   }
 
   LIST_INSERT_HEAD(&e->entries, de, de_inotify_link);