From dc4fe0bb9de52afe1f1901b6b96c694b049147e4 Mon Sep 17 00:00:00 2001 From: Paul Merrill Date: Wed, 20 Jul 2011 16:31:21 -0700 Subject: [PATCH] use command line cache_ttl --- src/common.h | 7 ++++--- src/resourcer.cpp | 6 +++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/common.h b/src/common.h index ebe2a7a..c449d45 100644 --- a/src/common.h +++ b/src/common.h @@ -46,8 +46,8 @@ struct ClientValues { coord_t windowsize; bool fullscreen; bool cache_enabled; - unsigned int cache_ttl; - unsigned int cache_size; + int cache_ttl; + int cache_size; message_mode_t loglevel; }; @@ -55,7 +55,8 @@ struct ClientValues { bool parseBool(const std::string& s); //! Split a string by a delimiter. -std::vector splitStr(std::string str, const std::string& delimiter); +std::vector splitStr(std::string str, + const std::string& delimiter); //! Convert an integer to a representative string. std::string itostr(long in); diff --git a/src/resourcer.cpp b/src/resourcer.cpp index b3c659b..f9a1141 100644 --- a/src/resourcer.cpp +++ b/src/resourcer.cpp @@ -84,7 +84,11 @@ void Resourcer::reclaim(Map& map) cache.lastUsed = now; Log::dbg("Resourcer", name + " unused"); } - else if (now > cache.lastUsed + CACHE_EMPTY_TTL*1000) { + else if (now < cache.lastUsed) { + // Handle time overflow + cache.lastUsed = now; + } + else if (now > cache.lastUsed + conf->cache_ttl*1000) { dead.push_back(name); Log::dbg("Resourcer", "Removing " + name); } -- 2.11.4.GIT