From 2ec184b3242dc725be2fce7e7afd633c7ba6271c Mon Sep 17 00:00:00 2001
From: Craig Tiller <craig.tiller@gmail.com>
Date: Wed, 1 Jun 2016 13:03:17 -0700
Subject: [PATCH] Fix formatting bug leading to crash

---
 src/core/ext/client_config/subchannel.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/core/ext/client_config/subchannel.c b/src/core/ext/client_config/subchannel.c
index c6c7b7a3a0..290cac8a43 100644
--- a/src/core/ext/client_config/subchannel.c
+++ b/src/core/ext/client_config/subchannel.c
@@ -638,10 +638,15 @@ static void subchannel_connected(grpc_exec_ctx *exec_ctx, void *arg,
         "connect_failed");
     gpr_timespec time_til_next = gpr_time_sub(c->next_attempt, now);
     const char *errmsg = grpc_error_string(error);
-    gpr_log(GPR_INFO, "Connect failed, retry in %d.%09d seconds: %s",
-            time_til_next.tv_sec, time_til_next.tv_nsec, errmsg);
-    grpc_error_free_string(errmsg);
+    gpr_log(GPR_INFO, "Connect failed: %s", errmsg);
+    if (gpr_time_cmp(time_til_next, gpr_time_0(time_til_next.clock_type)) <= 0) {
+      gpr_log(GPR_INFO, "Retry immediately");
+    } else {
+      gpr_log(GPR_INFO, "Retry in %d.%09d seconds",
+              time_til_next.tv_sec, time_til_next.tv_nsec);
+    }
     grpc_timer_init(exec_ctx, &c->alarm, c->next_attempt, on_alarm, c, now);
+    grpc_error_free_string(errmsg);
   }
   gpr_mu_unlock(&c->mu);
   GRPC_SUBCHANNEL_WEAK_UNREF(exec_ctx, c, "connecting");
-- 
GitLab