timeshift_filemgr: move the reaper lock to the end of loop to save the lock time

.... as suggested by Adam
This commit is contained in:
Jaroslav Kysela 2014-05-21 14:25:00 +02:00
parent d490918540
commit dd6b47dcf8

View file

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