* Fixed telelogger to output at least one dump after shared memory got reattached.
authorUrban Wallasch <urban.wallasch@freenet.de>
Sun, 18 Aug 2019 12:49:12 +0000 (14:49 +0200)
committerUrban Wallasch <urban.wallasch@freenet.de>
Sun, 18 Aug 2019 12:49:12 +0000 (14:49 +0200)
telelogger.c

index 721724e73e2e8cc38051bbc59c938c7b756f9fec..06927316a8cf02d2be8647794a19453913843b94 100644 (file)
@@ -16,6 +16,9 @@
 
 static struct telemetry_state_t *telemetry;
 
+static bool last_paused;
+static uint64_t last_timestamp;
+
 struct {
     int count;
     int delay;
@@ -53,6 +56,8 @@ static int init_shm( bool retry ) {
         }
     } while ( NULL == telemetry );
 
+    last_paused = false;
+    last_timestamp = -1ULL;
     return 0;
 }
 
@@ -70,9 +75,8 @@ static int check_shm( bool retry ) {
 static int log_console( int cnt, int delay ) {
     char buf[4096];
     bool forever = !cnt;
-    bool last_paused = telemetry->paused;
-    uint64_t last_timestamp = telemetry->timestamp;
 
+    last_timestamp = telemetry->timestamp;
     while ( forever || cnt-- > 0 ) {
         if ( 0 != check_shm( cfg.retry ) )
             return -1;
@@ -82,7 +86,7 @@ static int log_console( int cnt, int delay ) {
 
         if ( forever || cnt > 0 ) {
             if ( last_paused && telemetry->paused && cfg.pause ) {
-                while ( telemetry->paused ) {
+                while ( last_paused && telemetry->paused ) {
                     if ( 0 != check_shm( cfg.retry ) )
                         return -1;
                     usleep( 10000 );