]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
timeshift: more log cleanups, fix the wrong total updates
authorJaroslav Kysela <perex@perex.cz>
Sun, 13 Dec 2015 18:58:35 +0000 (19:58 +0100)
committerJaroslav Kysela <perex@perex.cz>
Sun, 13 Dec 2015 18:58:35 +0000 (19:58 +0100)
src/timeshift/private.h
src/timeshift/timeshift_filemgr.c
src/timeshift/timeshift_writer.c

index 5f193fbc0af866d99ba1b49178ad45f5c8549c58..b112b060e1d1ba3fb7b8091357e8658fa7bed351 100644 (file)
@@ -118,6 +118,12 @@ typedef struct timeshift {
 
 } timeshift_t;
 
+/*
+ *
+ */
+extern uint64_t timeshift_total_size;
+extern uint64_t timeshift_total_ram_size;
+
 /*
  * Write functions
  */
index 48fc358db02847446f06fd2a653861088cb13402..db0d8b0d2b916c8036e01a37612ce9f1b67bae71 100644 (file)
@@ -75,7 +75,7 @@ static void* timeshift_reaper_callback ( void *p )
           tvhlog(LOG_ERR, "timeshift", "failed to remove %s [e=%s]",
                  dpath, strerror(errno));
     } else {
-      tvhtrace("timeshift", "remove RAM segment (time %li)", (long)tsf->time);
+      tvhtrace("timeshift", "remove RAM segment (time %"PRItime_t", size %"PRId64")", tsf->time, (int64_t)tsf->size);
     }
 
     /* Free memory */
@@ -152,8 +152,7 @@ int timeshift_filemgr_makedirs ( int index, char *buf, size_t len )
 void timeshift_filemgr_close ( timeshift_file_t *tsf )
 {
   ssize_t r = timeshift_write_eof(tsf);
-  if (r > 0)
-  {
+  if (r > 0) {
     tsf->size += r;
     atomic_add_u64(&timeshift_total_size, r);
     if (tsf->ram)
@@ -175,9 +174,9 @@ void timeshift_filemgr_remove
   assert(tsf->rfd < 0);
   if (tvhtrace_enabled()) {
     if (tsf->path)
-      tvhdebug("timeshift", "ts %d remove %s", ts->id, tsf->path);
+      tvhdebug("timeshift", "ts %d remove %s (size %"PRId64")", ts->id, tsf->path, (int64_t)tsf->size);
     else
-      tvhdebug("timeshift", "ts %d RAM segment remove time %li", ts->id, (long)tsf->time);
+      tvhdebug("timeshift", "ts %d RAM segment remove time %"PRItime_t" (size %"PRId64", alloc size %"PRId64")", ts->id, tsf->time, (int64_t)tsf->size, (int64_t)tsf->ram_size);
   }
   TAILQ_REMOVE(&ts->files, tsf, link);
   atomic_dec_u64(&timeshift_total_size, tsf->size);
@@ -297,8 +296,8 @@ timeshift_file_t *timeshift_filemgr_get ( timeshift_t *ts, int create )
           free(tsf_tmp);
           tsf_tmp = NULL;
         } else {
-          tvhtrace("timeshift", "ts %d create RAM segment with %"PRId64" bytes (time %li)",
-                   ts->id, tsf_tmp->ram_size, (long)time);
+          tvhtrace("timeshift", "ts %d create RAM segment with %"PRId64" bytes (time %"PRItime_t")",
+                   ts->id, tsf_tmp->ram_size, time);
         }
       }
       
@@ -402,7 +401,7 @@ void timeshift_filemgr_init ( void )
 
   /* Size processing */
   timeshift_total_size = 0;
-  timeshift_conf.ram_size   = 0;
+  timeshift_conf.ram_size = 0;
 
   /* Start the reaper thread */
   timeshift_reaper_run = 1;
index ee611ad706e06401f25694a41278da37f3bc649f..b27fe5143068651fd5c5352e48366d151e94df49 100644 (file)
@@ -275,9 +275,9 @@ static inline ssize_t _process_msg0
   if (err > 0) {
     tsf->last  = sm->sm_time;
     tsf->size += err;
-    atomic_add_u64(&timeshift_conf.total_size, err);
+    atomic_add_u64(&timeshift_total_size, err);
     if (tsf->ram)
-      atomic_add_u64(&timeshift_conf.total_ram_size, err);
+      atomic_add_u64(&timeshift_total_ram_size, err);
   }
   return err;
 }