Skip to content

Commit

Permalink
mds: check if waiting is allocated before use
Browse files Browse the repository at this point in the history
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>
(cherry picked from commit 055020c)
  • Loading branch information
batrick committed Sep 14, 2017
1 parent d50f2c7 commit 97fdc68
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/mds/MDSCacheObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ class MDSCacheObject {

// ---------------------------------------------
// waiting
protected:
private:
alloc_ptr<mempool::mds_co::multimap<uint64_t, std::pair<uint64_t, MDSInternalContextBase*>>> waiting;
static uint64_t last_wait_seq;

Expand All @@ -310,13 +310,13 @@ class MDSCacheObject {
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;
}
Expand All @@ -339,7 +339,7 @@ class MDSCacheObject {

}
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;
Expand Down

0 comments on commit 97fdc68

Please sign in to comment.