]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/MonClient: fix auth timeout vs error race
authorSage Weil <sage@redhat.com>
Mon, 5 Mar 2018 18:59:32 +0000 (12:59 -0600)
committerSage Weil <sage@redhat.com>
Tue, 6 Mar 2018 20:44:50 +0000 (14:44 -0600)
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 <sage@redhat.com>
src/mon/MonClient.cc

index b21eb3f9a82b0ba06c586a33b3b431217e18b330..b246c064006dde8d2cce5ad0fb694408408edec7 100644 (file)
@@ -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;
       }