From: Sage Weil Date: Mon, 17 Nov 2014 16:01:15 +0000 (-0800) Subject: osd: rejigger watch connect/disconnect callers X-Git-Tag: v0.91~91 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9d9e66e663996a9646c761206ff7c1b779f4c8f7;p=ceph.git osd: rejigger watch connect/disconnect callers Signed-off-by: Sage Weil --- diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 1ddd738bef1..480dfcf9527 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -4328,7 +4328,9 @@ int ReplicatedPG::do_osd_ops(OpContext *ctx, vector& ops) } map,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; } diff --git a/src/osd/Watch.cc b/src/osd/Watch.cc index 33e39a85129..bccd0f70161 100644 --- a/src/osd/Watch.cc +++ b/src/osd/Watch.cc @@ -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; diff --git a/src/osd/Watch.h b/src/osd/Watch.h index 793229a703a..1c72adc8eee 100644 --- a/src/osd/Watch.h +++ b/src/osd/Watch.h @@ -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);