From: Jaroslav Kysela Date: Sat, 1 Dec 2018 16:30:33 +0000 (+0100) Subject: imagecache: try to fix the state handling, fixes #5382 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92b96d5efdcf57401bb1d5e204fa0d102afff2c5;p=thirdparty%2Ftvheadend.git imagecache: try to fix the state handling, fixes #5382 --- diff --git a/src/imagecache.c b/src/imagecache.c index ab0b60f30..e0c963319 100644 --- a/src/imagecache.c +++ b/src/imagecache.c @@ -343,7 +343,6 @@ error: if (NULL != hc) http_client_close(hc); urlreset(&url); tvhpoll_destroy(efd); - img->state = IDLE; time(&img->updated); // even if failed (possibly request sooner?) if (res) { if (!img->failed) { @@ -379,9 +378,12 @@ imagecache_thread ( void *p ) continue; } + TAILQ_REMOVE(&imagecache_queue, img, q_link); + if (img->state == SAVE) { /* Do save outside global mutex */ htsmsg_t *m = imagecache_image_htsmsg(img); + img->state = IDLE; tvh_mutex_unlock(&global_lock); hts_settings_save(m, "imagecache/meta/%d", img->id); htsmsg_destroy(m); @@ -390,10 +392,13 @@ imagecache_thread ( void *p ) } else if (img->state == QUEUED) { /* Process */ img->state = FETCHING; - TAILQ_REMOVE(&imagecache_queue, img, q_link); /* Fetch */ (void)imagecache_image_fetch(img); + img->state = IDLE; + + } else { + img->state = IDLE; } } tvh_mutex_unlock(&global_lock); @@ -694,7 +699,7 @@ imagecache_get_id ( const char *url ) i->accessed = clk; save = 1; } - if (save || i->state != IDLE) + if (save) imagecache_image_save(i); #endif return id;