]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
const-ified where possible, added cbdata checks.
authorFrancesco Chemolli <kinkie@squid-cache.org>
Wed, 2 Sep 2015 16:44:17 +0000 (18:44 +0200)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Wed, 2 Sep 2015 16:44:17 +0000 (18:44 +0200)
src/auth/UserNameCache.cc
src/auth/UserNameCache.h

index 32e468108364d16286ac4ceef896545275a7aca6..1eee7e1dc42534b000bcf915b4856294467d293f 100644 (file)
@@ -25,7 +25,7 @@ UserNameCache::UserNameCache(const char *name) :
 }
 
 Auth::User::Pointer
-UserNameCache::lookup(const SBuf &userKey)
+UserNameCache::lookup(const SBuf &userKey) const
 {
     auto p = store_.find(userKey);
     if (p == store_.end())
@@ -36,6 +36,8 @@ UserNameCache::lookup(const SBuf &userKey)
 void
 UserNameCache::Cleanup(void *data)
 {
+    if (!cbdataReferenceValid(data))
+        return;
     // data is this in disguise
     UserNameCache *self = static_cast<UserNameCache *>(data);
     // cache entries with expiretime <= expirationTime are to be evicted
@@ -56,7 +58,7 @@ UserNameCache::insert(Auth::User::Pointer anAuth_user)
 // generates the list of cached usernames in a format that is convenient
 // to merge with equivalent lists obtained from other UserNameCaches.
 std::vector<Auth::User::Pointer>
-UserNameCache::sortedUsersList()
+UserNameCache::sortedUsersList() const
 {
     std::vector<Auth::User::Pointer> rv(size(), nullptr);
     std::transform(store_.begin(), store_.end(), rv.begin(),
index 219276065104771176497e67e5dbb5b4da1c98fc..5409abcfbd6af38228cab312715c4f5dc2b10a26 100644 (file)
@@ -40,7 +40,7 @@ public:
     UserNameCache& operator=(const UserNameCache&) = delete;
 
     /// obtain pointer to user if present, or Pointer(nullptr) if not
-    Auth::User::Pointer lookup(const SBuf &userKey);
+    Auth::User::Pointer lookup(const SBuf &userKey) const;
 
     /// add an user to the cache
     void insert(Auth::User::Pointer anAuth_user);
@@ -49,7 +49,7 @@ public:
     void reset() { store_.clear(); }
 
     /// extract number of cached usernames
-    size_t size() { return store_.size(); }
+    size_t size() const { return store_.size(); }
 
     /** periodic cleanup function, removes timed-out entries
      *
@@ -60,10 +60,11 @@ public:
     /** obtain sorted list of usernames
      *
      */
-    std::vector<Auth::User::Pointer> sortedUsersList();
+    std::vector<Auth::User::Pointer> sortedUsersList() const;
 
     /// RegisteredRunner API
     virtual void endingShutdown() override;
+
 private:
     StoreType store_;