From 148db39cf9216cbbcca7faea3efed1f2200e61d4 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 5 Mar 2018 12:59:32 -0600 Subject: [PATCH] mon/MonClient: fix auth timeout vs error race It's possible that we successfully set active_con *and* time out the cond WaitUntil. Only set the error if we don't have a connection; if we set it *and* time out then let's call it success. Signed-off-by: Sage Weil --- src/mon/MonClient.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mon/MonClient.cc b/src/mon/MonClient.cc index b21eb3f9a82..b246c064006 100644 --- a/src/mon/MonClient.cc +++ b/src/mon/MonClient.cc @@ -494,10 +494,11 @@ int MonClient::authenticate(double timeout) until += timeout; if (timeout > 0.0) ldout(cct, 10) << "authenticate will time out at " << until << dendl; + authenticate_err = 0; while (!active_con && !authenticate_err) { if (timeout > 0.0) { int r = auth_cond.WaitUntil(monc_lock, until); - if (r == ETIMEDOUT) { + if (r == ETIMEDOUT && !active_con) { ldout(cct, 0) << "authenticate timed out after " << timeout << dendl; authenticate_err = -r; } -- 2.39.5