]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
timeshift_filemgr: move the reaper lock to the end of loop to save the lock time
authorJaroslav Kysela <perex@perex.cz>
Wed, 21 May 2014 12:25:00 +0000 (14:25 +0200)
committerJaroslav Kysela <perex@perex.cz>
Wed, 21 May 2014 12:27:16 +0000 (14:27 +0200)
.... as suggested by Adam

src/timeshift/timeshift_filemgr.c

index d33be2810fbd5ad8e33936a1c488f186eb188598..19f19bb74599aa48a4296c80a21a9536da4e2b19 100644 (file)
@@ -73,8 +73,6 @@ static void* timeshift_reaper_callback ( void *p )
         tvhlog(LOG_ERR, "timeshift", "failed to remove %s [e=%s]",
                dpath, strerror(errno));
 
-    pthread_mutex_lock(&timeshift_reaper_lock);
-
     /* Free memory */
     while ((ti = TAILQ_FIRST(&tsf->iframes))) {
       TAILQ_REMOVE(&tsf->iframes, ti, link);
@@ -88,6 +86,8 @@ static void* timeshift_reaper_callback ( void *p )
     }
     free(tsf->path);
     free(tsf);
+
+    pthread_mutex_lock(&timeshift_reaper_lock);
   }
   pthread_mutex_unlock(&timeshift_reaper_lock);
   tvhtrace("timeshift", "reaper thread exit");