}
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;
}
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,
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;
return last_ping;
}
+ bool is_connected() {
+ return conn.get() != NULL;
+ }
+
/// send a failed notify message
void send_failed_notify(Notify *notif);