From 94c5352db69d2bd0e5f7df6ab4b7379e84da79de Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Mon, 8 Sep 2014 21:57:52 +0200 Subject: [PATCH] Remove EVLOOP_ONCE calls in filescanner These calls generate error messages when the loop is already running, which will be the case when using init-rescan or full-rescan. The only purpose of these calls seems to be to check for exit signals from the main thread during a startup bulk scan, where the loop is not running yet. However, we can check for an exit signal by just setting/checking scan_exit. This commit also removes the unused filescanner_status(). --- src/filescanner.c | 34 +++++----------------------------- src/filescanner.h | 3 --- 2 files changed, 5 insertions(+), 32 deletions(-) diff --git a/src/filescanner.c b/src/filescanner.c index 26817663..8440c86c 100644 --- a/src/filescanner.c +++ b/src/filescanner.c @@ -656,9 +656,6 @@ process_deferred_playlists(void) free(pl->path); free(pl); - /* Run the event loop */ - event_base_loop(evbase_scan, EVLOOP_ONCE | EVLOOP_NONBLOCK); - if (scan_exit) return; } @@ -782,7 +779,6 @@ check_speciallib(char *path, const char *libtype) static void process_directory(char *path, int flags) { - struct stacked_dir *bulkstack; DIR *dirp; struct dirent buf; struct dirent *de; @@ -796,24 +792,6 @@ process_directory(char *path, int flags) int type; int ret; - if (flags & F_SCAN_BULK) - { - /* Save our directory stack so it won't get handled inside - * the event loop - not its business, we're in bulk mode here. - */ - bulkstack = dirstack; - dirstack = NULL; - - /* Run the event loop */ - event_base_loop(evbase_scan, EVLOOP_ONCE | EVLOOP_NONBLOCK); - - /* Restore our directory stack */ - dirstack = bulkstack; - - if (scan_exit) - return; - } - DPRINTF(E_DBG, L_SCAN, "Processing directory %s (flags = 0x%x)\n", path, flags); dirp = opendir(path); @@ -835,6 +813,9 @@ process_directory(char *path, int flags) for (;;) { + if (scan_exit) + break; + ret = readdir_r(dirp, &buf, &de); if (ret != 0) { @@ -1799,13 +1780,6 @@ exit_cb(int fd, short event, void *arg) scan_exit = 1; } - -int -filescanner_status(void) -{ - return scan_exit; -} - /* Thread: main */ int filescanner_init(void) @@ -1909,6 +1883,8 @@ filescanner_deinit(void) } #endif + scan_exit = 1; + ret = pthread_join(tid_scan, NULL); if (ret != 0) { diff --git a/src/filescanner.h b/src/filescanner.h index 07c8ea9b..97c628e8 100644 --- a/src/filescanner.h +++ b/src/filescanner.h @@ -18,9 +18,6 @@ filescanner_init(void); void filescanner_deinit(void); -int -filescanner_status(void); - void filescanner_process_media(char *path, time_t mtime, off_t size, int type, struct media_file_info *external_mfi);