Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 411ea7f2 authored by Mike Yu's avatar Mike Yu
Browse files

Convert to use libbase ScopedLockAssertion

The helper class was introduced in libbase few months ago.
No functionality change.

Test: built, flashed, booted
Change-Id: I9ce418ffc498f8d4767af64365e7dea0d1ba9574
parent f1e707cf
Loading
Loading
Loading
Loading
+1 −9
Original line number Diff line number Diff line
@@ -902,14 +902,6 @@ struct resolv_cache_info {
    std::unordered_map<int, uint32_t> dns_event_subsampling_map;
};

// A helper class for the Clang Thread Safety Analysis to deal with
// std::unique_lock.
class SCOPED_CAPABILITY ScopedAssumeLocked {
  public:
    explicit ScopedAssumeLocked(std::mutex& mutex) ACQUIRE(mutex) {}
    ~ScopedAssumeLocked() RELEASE() {}
};

// lock protecting everything in the resolve_cache_info structs (next ptr, etc)
static std::mutex cache_mutex;
static std::condition_variable cv;
@@ -1175,7 +1167,7 @@ ResolvCacheStatus resolv_cache_lookup(unsigned netid, const void* query, int que
    }
    /* lookup cache */
    std::unique_lock lock(cache_mutex);
    ScopedAssumeLocked assume_lock(cache_mutex);
    android::base::ScopedLockAssertion assume_lock(cache_mutex);
    cache = find_named_cache_locked(netid);
    if (cache == nullptr) {
        return RESOLV_CACHE_UNSUPPORTED;