]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ReplicatedPG: watchers must grab Connection ref as well
authorSamuel Just <sam.just@inktank.com>
Wed, 12 Dec 2012 22:06:51 +0000 (14:06 -0800)
committerSamuel Just <sam.just@inktank.com>
Wed, 12 Dec 2012 22:50:15 +0000 (14:50 -0800)
Session refs are not really valid on their own, the
corresponding Connection must remain live for at least
as long as the Session.

Signed-off-by: Samuel Just <sam.just@inktank.com>
src/osd/ReplicatedPG.cc

index 47abfdb2bd7f3a87faaef2fe72def0f03cdd4448..e6152678ed11c79f2bf21e3fb3f1e70058fc6287 100644 (file)
@@ -1586,6 +1586,7 @@ void ReplicatedPG::remove_watcher(ObjectContext *obc, entity_name_t entity)
   session->watches.erase(obc);
 
   put_object_context(obc);
+  session->con->put();
   session->put();
 }
 
@@ -3345,6 +3346,7 @@ void ReplicatedPG::do_osd_op_effects(OpContext *ctx)
       if (iter == obc->watchers.end()) {
        dout(10) << " connected to " << w << " by " << entity << " session " << session << dendl;
        obc->watchers[entity] = session;
+       session->con->get();
        session->get();
        session->watches[obc] = get_osdmap()->object_locator_to_pg(soid.oid, obc->obs.oi.oloc);
        obc->ref++;
@@ -3356,10 +3358,14 @@ void ReplicatedPG::do_osd_op_effects(OpContext *ctx)
        // weird: same entity, different session.
        dout(10) << " reconnected (with different session!) watch " << w << " by " << entity
                 << " session " << session << " (was " << iter->second << ")" << dendl;
+       session->con->get();
+       session->get();
+
        iter->second->watches.erase(obc);
+       iter->second->con->put();
        iter->second->put();
+
        iter->second = session;
-       session->get();
        session->watches[obc] = get_osdmap()->object_locator_to_pg(soid.oid, obc->obs.oi.oloc);
       }
       map<entity_name_t,Watch::C_WatchTimeout*>::iterator un_iter =