From kde-commits Mon Jul 30 17:54:11 2012 From: =?utf-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Mon, 30 Jul 2012 17:54:11 +0000 To: kde-commits Subject: icecream/daemon Message-Id: <20120730175411.4211DAC7A9 () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=134367112401795 SVN commit 1308593 by lunakl: check env cache size also when creating new native environment Otherwise too many plugin combinations (or the host never getting new envs from other hosts) could make the cache grow a lot. M +14 -7 main.cpp --- trunk/icecream/daemon/main.cpp #1308592:1308593 @@ -472,6 +472,7 @@ bool reconnect(); int working_loop(); bool setup_listen_fds(); + void check_cache_size( const string &new_env ); }; bool Daemon::setup_listen_fds() @@ -846,7 +847,17 @@ log_error() << "installed " << current << " size: " << installed_size << " all: " << cache_size << endl; } + check_cache_size( current ); + bool r = reannounce_environments(); // do that before the file compiles + // we do that here so we're not given out in case of full discs + if ( !maybe_stats(true) ) + r = false; + return r; +} + +void Daemon::check_cache_size( const string &new_env ) +{ time_t now = time( NULL ); while ( cache_size > cache_size_limit ) { string oldest; @@ -889,7 +900,7 @@ } } } - if ( oldest.empty() || oldest == current ) + if ( oldest.empty() || oldest == new_env ) break; size_t removed; if (oldest_is_native) { @@ -902,12 +913,6 @@ cache_size -= min( removed, cache_size ); envs_last_use.erase( oldest ); } - - bool r = reannounce_environments(); // do that before the file compiles - // we do that here so we're not given out in case of full discs - if ( !maybe_stats(true) ) - r = false; - return r; } bool Daemon::handle_get_native_env( Client *client, GetNativeEnvMsg *msg ) @@ -957,6 +962,8 @@ } env.extrafilestimes = extrafilestimes; save_compiler_timestamps(env.gcc_bin_timestamp, env.gpp_bin_timestamp, env.clang_bin_timestamp); + envs_last_use[ native_environments[ env_key ].name ] = time( NULL ); + check_cache_size( env.name ); } UseNativeEnvMsg m( native_environments[ env_key ].name ); if (!client->channel->send_msg( m )) {