From 038518aa6b37aa7950fbbbd5d3b2ff93c2ae52dd Mon Sep 17 00:00:00 2001
From: Francois Rousseau <frousseau@google.com>
Date: Wed, 24 Apr 2019 22:58:28 +0000
Subject: [PATCH] [feedback] check for PostDelayedTask return status

* it turns out async::PostDelayedTask returns a status so we might as well log an error if we couldn't post the timeout!

TESTED=I don't know an easy way to make the async loop reject the task :-(

Change-Id: I99b3a685f8ac2176aa0274890bc2a51e6661ce91
---
 src/developer/feedback_agent/log_listener.cc | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/developer/feedback_agent/log_listener.cc b/src/developer/feedback_agent/log_listener.cc
index dd49603ba76..28ef0809c77 100644
--- a/src/developer/feedback_agent/log_listener.cc
+++ b/src/developer/feedback_agent/log_listener.cc
@@ -80,7 +80,7 @@ fit::promise<void> LogListener::CollectLogs() {
 
   // fit::promise does not have the notion of a timeout. So we post a delayed
   // task that will call the completer after the timeout and return an error.
-  async::PostDelayedTask(
+  const zx_status_t post_status = async::PostDelayedTask(
       async_get_default_dispatcher(),
       [this] {
         // Check that the fit::bridge was not already completed by Done() or
@@ -91,6 +91,11 @@ fit::promise<void> LogListener::CollectLogs() {
         }
       },
       kSystemLogCollectionTimeout);
+  if (post_status != ZX_OK) {
+    FX_LOGS(ERROR)
+        << "Failed to post delayed task, no timeout for log collection: "
+        << post_status << " (" << zx_status_get_string(post_status) << ")";
+  }
 
   return done_.consumer.promise_or(fit::error());
 }
-- 
GitLab