]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Issue #1622 - timeshift: remove post double list removal
authorAdam Sutton <dev@adamsutton.me.uk>
Sat, 16 Feb 2013 19:31:24 +0000 (19:31 +0000)
committerAdam Sutton <dev@adamsutton.me.uk>
Thu, 21 Feb 2013 16:00:00 +0000 (16:00 +0000)
(cherry picked from commit dace3778559f705254afde27dcd492db34ac8ab2)

src/timeshift/timeshift_filemgr.c

index cf6906e237cd2cbed8121699da9d5e568ccbf9b7..5ce488e07a6cab2c8eec1778be4980073646f591 100644 (file)
@@ -161,7 +161,7 @@ void timeshift_filemgr_remove
 {
   if (tsf->fd != -1)
     close(tsf->fd);
-  tvhlog(LOG_DEBUG, "timeshift", "ts %d remove %s\n", ts->id, tsf->path);
+  tvhlog(LOG_DEBUG, "timeshift", "ts %d remove %s", ts->id, tsf->path);
   TAILQ_REMOVE(&ts->files, tsf, link);
   atomic_add_u64(&timeshift_total_size, -tsf->size);
   timeshift_reaper_remove(tsf);
@@ -216,6 +216,7 @@ timeshift_file_t *timeshift_filemgr_get ( timeshift_t *ts, int create )
       if (d > (ts->max_time+5)) {
         if (!tsf_hd->refcount) {
           timeshift_filemgr_remove(ts, tsf_hd, 0);
+          tsf_hd = NULL;
         } else {
           tvhlog(LOG_DEBUG, "timeshift", "ts %d buffer full", ts->id);
           ts->full = 1;
@@ -228,12 +229,12 @@ timeshift_file_t *timeshift_filemgr_get ( timeshift_t *ts, int create )
         atomic_pre_add_u64(&timeshift_total_size, 0) >= timeshift_max_size) {
 
       /* Remove the last file (if we can) */
-      if (!tsf_hd->refcount) {
+      if (tsf_hd && !tsf_hd->refcount) {
         timeshift_filemgr_remove(ts, tsf_hd, 0);
 
       /* Full */
       } else {
-        tvhlog(LOG_DEBUG, "timshift", "ts %d buffer full", ts->id);
+        tvhlog(LOG_DEBUG, "timeshift", "ts %d buffer full", ts->id);
         ts->full = 1;
       }
     }