From f021ec9592ea33b2def1f317c939d7de30cb9440 Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Sat, 19 Jan 2013 19:48:47 +0000 Subject: [PATCH] dvr: stop inotify code asserting, output error instead. --- src/dvr/dvr_inotify.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/dvr/dvr_inotify.c b/src/dvr/dvr_inotify.c index 22c6d22b..7d6f177c 100644 --- a/src/dvr/dvr_inotify.c +++ b/src/dvr/dvr_inotify.c @@ -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);