Lower the priority of the thread so forked-daapd may still respond

during file scan on low power devices
This commit is contained in:
ejurgensen 2014-09-07 13:48:03 +02:00
parent 2545aedc2a
commit d2d85b29f4

View File

@ -1074,8 +1074,20 @@ bulk_scan(int flags)
static void * static void *
filescanner(void *arg) filescanner(void *arg)
{ {
struct sched_param param;
int ret; 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(&param, 0, sizeof(struct sched_param));
ret = pthread_setschedparam(pthread_self(), SCHED_BATCH, &param);
if (ret != 0)
{
DPRINTF(E_LOG, L_SCAN, "Warning: Could not set thread priority to SCHED_BATCH\n");
}
ret = db_perthread_init(); ret = db_perthread_init();
if (ret < 0) if (ret < 0)
{ {