]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: check if waiting is allocated before use
authorPatrick Donnelly <pdonnell@redhat.com>
Tue, 12 Sep 2017 21:31:18 +0000 (14:31 -0700)
committerPatrick Donnelly <pdonnell@redhat.com>
Tue, 12 Sep 2017 22:46:23 +0000 (15:46 -0700)
This prevents accidental allocation of the map.

Also, privatize the variable to protect from this in child classes.

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/mds/MDSCacheObject.h

index 96493d4dd8cf78e54c1a4b1d7e9011e0e0465c4d..7f12e80953f9dde4c5ed84fdac20fa289965a52f 100644 (file)
@@ -301,7 +301,7 @@ protected:
 
   // ---------------------------------------------
   // waiting
- protected:
+ private:
   alloc_ptr<mempool::mds_co::multimap<uint64_t, std::pair<uint64_t, MDSInternalContextBase*>>> waiting;
   static uint64_t last_wait_seq;
 
@@ -310,13 +310,13 @@ protected:
     if (!min) {
       min = mask;
       while (min & (min-1))  // if more than one bit is set
-       min &= min-1;        //  clear LSB
+        min &= min-1;        //  clear LSB
     }
-    for (auto p = waiting->lower_bound(min);
-        p != waiting->end();
-        ++p) {
-      if (p->first & mask) return true;
-      if (p->first > mask) return false;
+    if (waiting) {
+      for (auto p = waiting->lower_bound(min); p != waiting->end(); ++p) {
+        if (p->first & mask) return true;
+        if (p->first > mask) return false;
+      }
     }
     return false;
   }
@@ -339,7 +339,7 @@ protected:
     
   }
   virtual void take_waiting(uint64_t mask, std::list<MDSInternalContextBase*>& ls) {
-    if (waiting->empty()) return;
+    if (!waiting || waiting->empty()) return;
 
     // process ordered waiters in the same order that they were added.
     std::map<uint64_t, MDSInternalContextBase*> ordered_waiters;