fix bugs with actions related to skipping rapid status updates

Change-Id: Ib5e11ddc33b15c2eaa29ee7f55fcedd455e3621f
diff --git a/aos/common/actions/actions.h b/aos/common/actions/actions.h
index c729b3f..fa89995 100644
--- a/aos/common/actions/actions.h
+++ b/aos/common/actions/actions.h
@@ -11,6 +11,7 @@
 
 #include "aos/common/logging/logging.h"
 #include "aos/common/queue.h"
+#include "aos/common/logging/queue_logging.h"
 
 namespace aos {
 namespace common {
@@ -126,6 +127,9 @@
         queue_group_->goal.name());
     // Clear out any old status messages from before now.
     queue_group_->status.FetchLatest();
+    if (queue_group_->status.get()) {
+      LOG_STRUCT(DEBUG, "have status", *queue_group_->status);
+    }
   }
 
   virtual ~TypedAction() {
@@ -225,8 +229,12 @@
   if (has_started_) {
     queue_group_->status.FetchNext();
     CheckInterrupted();
-  } else if (queue_group_->status.FetchLatest()) {
-    CheckStarted();
+  } else {
+    while (queue_group_->status.FetchNext()) {
+      LOG_STRUCT(DEBUG, "got status", *queue_group_->status);
+      CheckStarted();
+      if (has_started_) CheckInterrupted();
+    }
   }
   if (interrupted_) return false;
   // We've asked it to start but haven't gotten confirmation that it's started
@@ -240,6 +248,7 @@
 void TypedAction<T>::DoWaitUntilDone() {
   CHECK(sent_started_);
   queue_group_->status.FetchNext();
+  LOG_STRUCT(DEBUG, "got status", *queue_group_->status);
   CheckInterrupted();
   while (true) {
     if (DoCheckIteration(true)) {
@@ -254,11 +263,13 @@
   if (interrupted_) return true;
   CheckStarted();
   if (blocking) {
-    queue_group_->status.FetchAnother();
+    queue_group_->status.FetchNextBlocking();
+    LOG_STRUCT(DEBUG, "got status", *queue_group_->status);
   } else {
     if (!queue_group_->status.FetchNext()) {
       return false;
     }
+    LOG_STRUCT(DEBUG, "got status", *queue_group_->status);
   }
   CheckStarted();
   CheckInterrupted();
@@ -278,7 +289,7 @@
          queue_group_->status->last_running == run_value_)) {
       // It's currently running our instance.
       has_started_ = true;
-      LOG(DEBUG, "Action %" PRIx32 " on queue %s has been started\n",
+      LOG(INFO, "Action %" PRIx32 " on queue %s has been started\n",
           run_value_, queue_group_->goal.name());
     } else if (old_run_value_ != 0 &&
                queue_group_->status->running == old_run_value_) {
@@ -320,7 +331,10 @@
       // Don't wait to see a message with it.
       has_started_ = true;
     }
-    queue_group_->status.FetchLatest();
+    queue_group_->status.FetchNext();
+    if (queue_group_->status.get()) {
+      LOG_STRUCT(DEBUG, "got status", *queue_group_->status);
+    }
     if (queue_group_->status.get() && queue_group_->status->running != 0) {
       old_run_value_ = queue_group_->status->running;
       LOG(INFO, "Action %" PRIx32 " on queue %s already running\n",