]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
monc: fix authentication timeout
authorSage Weil <sage@newdream.net>
Sat, 6 Feb 2010 19:27:17 +0000 (11:27 -0800)
committerSage Weil <sage@newdream.net>
Sat, 6 Feb 2010 19:27:41 +0000 (11:27 -0800)
src/mon/MonClient.cc
src/mon/MonClient.h

index fd4509718e3bdadc3688842578c9cde0a8e439f5..a1323c98885891ad6955803c736f6435647159aa 100644 (file)
@@ -272,8 +272,20 @@ int MonClient::authenticate(double timeout)
   if (cur_mon < 0)
     _reopen_session();
 
-  while (state != MC_STATE_HAVE_SESSION && !authenticate_err)
-    auth_cond.Wait(monc_lock);
+  utime_t until = g_clock.now();
+  until += timeout;
+  if (timeout > 0.0)
+    dout(10) << "authenticate will time out at " << until << dendl;
+  while (state != MC_STATE_HAVE_SESSION && !authenticate_err) {
+    if (timeout > 0.0) {
+      int r = auth_cond.WaitUntil(monc_lock, until);
+      if (r == ETIMEDOUT) {
+       dout(0) << "authenticate timed out after " << timeout << dendl;
+       authenticate_err = -r;
+      }
+    } else
+      auth_cond.Wait(monc_lock);
+  }
 
   if (state == MC_STATE_HAVE_SESSION) {
     dout(5) << "authenticate success, global_id " << global_id << dendl;
index 699dd378df195db309b7a29c3542ff9cf676a554..eb4b4ccd08b02a42199c3c86684d91c30af5ef30 100644 (file)
@@ -109,7 +109,7 @@ public:
   int _check_auth_rotating();
   int wait_auth_rotating(double timeout);
 
-  int authenticate(double timeout=30.0);
+  int authenticate(double timeout=0.0);
 
   // mon subscriptions
 private: