]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: rejigger watch connect/disconnect callers
authorSage Weil <sage@redhat.com>
Mon, 17 Nov 2014 16:01:15 +0000 (08:01 -0800)
committerSage Weil <sage@redhat.com>
Thu, 4 Dec 2014 18:34:05 +0000 (10:34 -0800)
Signed-off-by: Sage Weil <sage@redhat.com>
src/osd/ReplicatedPG.cc
src/osd/Watch.cc
src/osd/Watch.h

index 1ddd738bef1b330acf22ffa169b6ef54d1f922a1..480dfcf9527d184610766403bdb8125cfec5d7ab 100644 (file)
@@ -4328,7 +4328,9 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector<OSDOp>& ops)
          }
          map<pair<uint64_t,entity_name_t>,WatchRef>::iterator p =
            obc->watchers.find(make_pair(cookie, entity));
-         if (p == obc->watchers.end()) {
+         if (p == obc->watchers.end() ||
+             !p->second->is_connected()) {
+           // client needs to reconnect
            result = -ETIMEDOUT;
            break;
          }
index 33e39a85129493a74b7d123ec0cbbdeb9937d968..bccd0f70161ec44d58abaa8fd4c56347f8fc90cd 100644 (file)
@@ -315,8 +315,13 @@ Context *Watch::get_delayed_cb()
 void Watch::register_cb()
 {
   Mutex::Locker l(osd->watch_lock);
-  dout(15) << "registering callback, timeout: " << timeout << dendl;
-  assert(cb == NULL);
+  if (cb) {
+    dout(15) << "re-registering callback, timeout: " << timeout << dendl;
+    cb->cancel();
+    osd->watch_timer.cancel_event(cb);
+  } else {
+    dout(15) << "registering callback, timeout: " << timeout << dendl;
+  }
   cb = new HandleWatchTimeout(self.lock());
   osd->watch_timer.add_event_after(
     timeout,
@@ -340,13 +345,17 @@ void Watch::unregister_cb()
 void Watch::got_ping(utime_t t)
 {
   last_ping = t;
-  assert(conn);
-  unregister_cb();
-  register_cb();
+  if (conn) {
+    register_cb();
+  }
 }
 
 void Watch::connect(ConnectionRef con, bool _will_ping)
 {
+  if (conn == con) {
+    dout(10) << "connecting - already connected" << dendl;
+    return;
+  }
   dout(10) << "connecting" << dendl;
   conn = con;
   will_ping = _will_ping;
index 793229a703a10aa96de5e5879bf25c58e5e5b474..1c72adc8eee0357561bc274395cf09687a207281 100644 (file)
@@ -199,6 +199,10 @@ public:
     return last_ping;
   }
 
+  bool is_connected() {
+    return conn.get() != NULL;
+  }
+
   /// send a failed notify message
   void send_failed_notify(Notify *notif);