From d2d85b29f4203bc3ab3ac52a60bb92e4acd98d5e Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Sun, 7 Sep 2014 13:48:03 +0200 Subject: [PATCH] Lower the priority of the thread so forked-daapd may still respond during file scan on low power devices --- src/filescanner.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/filescanner.c b/src/filescanner.c index c9a6bfcf..26817663 100644 --- a/src/filescanner.c +++ b/src/filescanner.c @@ -1074,8 +1074,20 @@ bulk_scan(int flags) static void * filescanner(void *arg) { + struct sched_param param; int ret; + /* Lower the priority of the thread so forked-daapd may still respond + * during file scan on low power devices. Param must be 0 for the SCHED_BATCH + * policy. + */ + memset(¶m, 0, sizeof(struct sched_param)); + ret = pthread_setschedparam(pthread_self(), SCHED_BATCH, ¶m); + if (ret != 0) + { + DPRINTF(E_LOG, L_SCAN, "Warning: Could not set thread priority to SCHED_BATCH\n"); + } + ret = db_perthread_init(); if (ret < 0) {