From 68ea689819959fcaa770c22428eb521cd3931451 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 20 Sep 2004 21:49:54 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=4209 --- checkin_notes | 11 +++++++++++ html/inc/cache.inc | 46 +++++++++++++++++++++++++++++++++------------- html/inc/prefs.inc | 19 +++++++++---------- 3 files changed, 53 insertions(+), 23 deletions(-) diff --git a/checkin_notes b/checkin_notes index 155e81b013..58552650f8 100755 --- a/checkin_notes +++ b/checkin_notes @@ -17463,3 +17463,14 @@ David 18 Sept 2004 client/ whetstone.C + +David 20 Sept 2004 + - changed PHP caching code to touch file before regenerating it. + This will (in most cases) prevent concurrent processes + from redundantly regenerating it. + - Change "cpu_scheduling" to "cpu_scheduling_period_minutes" + in global preferences + + html/inc/ + cache.inc + prefs.inc diff --git a/html/inc/cache.inc b/html/inc/cache.inc index df39f3497d..1a226ddcca 100644 --- a/html/inc/cache.inc +++ b/html/inc/cache.inc @@ -75,7 +75,9 @@ function clean_cache($max_age, $dir) { function start_cache($max_age, $params=""){ $path = get_path($params); + // check free disk space every once in a while + // if (!(rand() % CACHE_SIZE_CHECK_FREQ)) { $too_old=86400; while ((disk_free_space("../cache") < MIN_FREE_SPACE) || @@ -84,26 +86,44 @@ function start_cache($max_age, $params=""){ $too_old/=2; } } + + $regenerate = false; if ($max_age) { $request = getallheaders(); - // Check to see if this is a conditional fetch. + $lastmodified = @filemtime($path); + if ($lastmodified) { - $if_modified_since = isset($request['If-Modified-Since']) ? - (explode(';',$request['If-Modified-Since'])) : - false; + // Check to see if this is a conditional fetch. + // + $if_modified_since = isset($request['If-Modified-Since']) ? + (explode(';',$request['If-Modified-Since'])) : + false; - if ($if_modified_since) { - $if_modified_since=strtotime($if_modified_since[0]); + if ($if_modified_since) { + $if_modified_since=strtotime($if_modified_since[0]); + } + + if ($if_modified_since && ($if_modified_since == $lastmodified)) { + Header("Last-Modified: " . gmdate("D, d M Y H:i:s",$lastmodified) . " GMT"); + Header('HTTP/1.0 304 Not Modified'); + exit; + } + + // See if cached copy is too old. + // If so regenerate, + // and touch the cached copy so other processes + // don't regenerate at the same time + // + if ($lastmodified(no restriction if equal)"); define("LEAVE_APPS_IN_MEMORY_DESC", "Leave applications in memory while preempted?
(suspended applications will consume swap space if 'yes')"); -define("CPU_SCHEDULING_DESC", "Schedule CPU between projects every -
(short cpu scheduling periods is recommended to use with above 'yes')"); +define("CPU_SCHEDULING_DESC", "Switch between applications every +
(recommended: 60 minutes)"); define("CONFIRM_BEFORE_CONNECTING_DESC", "Confirm before connecting to Internet?
(matters only if you use a modem)" @@ -215,8 +215,8 @@ function element_end_global($parser, $name) { case "leave_apps_in_memory": $parse_result->leave_apps_in_memory = true; break; - case "cpu_scheduling": - $parse_result->cpu_scheduling = $text; + case "cpu_scheduling_period_minutes": + $parse_result->cpu_scheduling_period_minutes = $text; break; case "confirm_before_connecting": $parse_result->confirm_before_connecting = true; @@ -276,7 +276,7 @@ function default_prefs_global() { $p->start_hour = 0; $p->end_hour = 0; $p->leave_apps_in_memory = false; - $p->cpu_scheduling = 60; + $p->cpu_scheduling_period_minutes = 60; $p->confirm_before_connecting = false; $p->hangup_if_dialed = true; $p->work_buf_min_days = .1; @@ -374,7 +374,7 @@ function prefs_show_global($prefs) { } row2(START_END_DESC, $x); row2(LEAVE_APPS_IN_MEMORY_DESC, $prefs->leave_apps_in_memory?"yes":"no"); - row2(CPU_SCHEDULING_DESC, "$prefs->cpu_scheduling minutes"); + row2(CPU_SCHEDULING_DESC, "$prefs->cpu_scheduling_period_minutes minutes"); row2(CONFIRM_BEFORE_CONNECTING_DESC, $prefs->confirm_before_connecting?"yes":"no"); row2(HANGUP_IF_DIALED_DESC, $prefs->hangup_if_dialed?"yes":"no"); row2(WORK_BUF_DESC, "$prefs->work_buf_min_days days"); @@ -519,7 +519,7 @@ function prefs_form_global($user, $prefs) { "; row2($x, $y); - $y = " minutes "; + $y = " minutes "; row2(CPU_SCHEDULING_DESC, $y); $x = CONFIRM_BEFORE_CONNECTING_DESC; @@ -673,7 +673,7 @@ function prefs_global_parse_form(&$prefs) { $prefs->start_hour = $_GET["start_hour"]; $prefs->end_hour = $_GET["end_hour"]; $prefs->leave_apps_in_memory = ($leave_apps_in_memory == "yes"); - $prefs->cpu_scheduling = $_GET["cpu_scheduling"]; + $prefs->cpu_scheduling_period_minutes = $_GET["cpu_scheduling_period_minutes"]; $prefs->confirm_before_connecting = ($confirm_before_connecting == "yes"); $prefs->hangup_if_dialed = ($hangup_if_dialed == "yes"); $prefs->confirm_eecutable = ($confirm_eecutable == "yes"); @@ -740,7 +740,7 @@ function global_prefs_make_xml($prefs, $primary=true) { if ($prefs->leave_apps_in_memory) { $xml = $xml."\n"; } - $xml = $xml."$prefs->cpu_scheduling\n"; + $xml = $xml."$prefs->cpu_scheduling_period_minutes\n"; if ($prefs->confirm_before_connecting) { $xml = $xml."\n"; } @@ -829,4 +829,3 @@ function project_prefs_update(&$user, $prefs) { } ?> -