]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
messages: MForward: get() message reference
authorJoao Eduardo Luis <joao@suse.de>
Tue, 14 Jul 2015 15:52:35 +0000 (16:52 +0100)
committerJoao Eduardo Luis <joao@suse.de>
Thu, 16 Jul 2015 17:31:23 +0000 (18:31 +0100)
Don't simply put() a reference if it has gone unclaimed without
get()'ing it first. This can cause nefarious consequences for those
users of MForward that do not expect this to happen.

Signed-off-by: Joao Eduardo Luis <joao@suse.de>
src/messages/MForward.h

index 4d1abff3f8bf4d17d389bae7a6a0aa1359d28a64..efe608563cd77029aa4c6a93f6c19ce0e284d580 100644 (file)
@@ -102,12 +102,12 @@ public:
   }
 
   void set_message(PaxosServiceMessage *m, uint64_t features) {
-    encode_message(m, features, msg_bl);
-
-    // keep a pointer to the message.  We will not use it except for print(),
-    // and we will drop it in the dtor if it is not claimed.
+    // get a reference to the message.  We will not use it except for print(),
+    // and we will put it in the dtor if it is not claimed.
     // we could avoid doing this if only we had a const bufferlist iterator :)
-    msg = m;
+    msg = (PaxosServiceMessage*)m->get();
+
+    encode_message(m, features, msg_bl);
   }
 
   PaxosServiceMessage *claim_message() {
@@ -115,6 +115,7 @@ public:
       return get_msg_from_bl();
     }
 
+    // let whoever is claiming the message deal with putting it.
     PaxosServiceMessage *m = msg;
     msg = NULL;
     return m;