summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUnbit <info@unbit.it>2014-10-13 13:00:07 +0200
committerUnbit <info@unbit.it>2014-10-13 13:00:07 +0200
commitf778e30d48ce6bfef7f5434c2e30b617189bbdf0 (patch)
treee124c44422731308605e15534043f5e4c0cfa755
parente071184d53e7b1bc0d67d91e92c2bc503d462b20 (diff)
downloaduwsgi-f778e30d48ce6bfef7f5434c2e30b617189bbdf0.tar.gz
run the sweeper only if required
-rw-r--r--core/cache.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/core/cache.c b/core/cache.c
index a3df2cfa..8cf9b1b2 100644
--- a/core/cache.c
+++ b/core/cache.c
@@ -1163,20 +1163,24 @@ void uwsgi_cache_start_sweepers() {
if (uwsgi.cache_no_expire)
return;
+ int need_to_run = 0;
while(uc) {
- pthread_t cache_sweeper;
- if (!uc->no_expire && !uc->purge_lru) {
- if (pthread_create(&cache_sweeper, NULL, cache_sweeper_loop, uwsgi.caches)) {
- uwsgi_error("pthread_create()");
- uwsgi_log("unable to run the sweeper!!!\n");
- }
- else {
- uwsgi_log("sweeper thread enabled\n");
- }
+ if (!uc->no_expire && !uc->purge_lru && !uc->lazy_expire) {
+ need_to_run = 1;
break;
}
uc = uc->next;
}
+
+ if (!need_to_run) return;
+
+ pthread_t cache_sweeper;
+ if (pthread_create(&cache_sweeper, NULL, cache_sweeper_loop, uwsgi.caches)) {
+ uwsgi_error("uwsgi_cache_start_sweepers()/pthread_create()");
+ uwsgi_log("unable to run the cache sweeper!!!\n");
+ return;
+ }
+ uwsgi_log("cache sweeper thread enabled\n");
}
void uwsgi_cache_start_sync_servers() {