From a0784db9659d852940965978db4438e0b37c4231 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Sun, 27 Mar 2011 17:28:38 +0200 Subject: [PATCH] garbage expire data externalized from original data structures --- web/Obj/brisk.phh | 4 +-- web/briskin5/Obj/briskin5.phh | 48 +++++++++++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index c74c141..6e0fcbb 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -2499,7 +2499,7 @@ class Room { do { if (file_exists(PROXY_PATH) == FALSE) mkdir(PROXY_PATH); - if (($fp = @fopen(PROXY_PATH."/room_garbage_time.expired", 'rb')) == FALSE) + if (($fp = @fopen(PROXY_PATH."/garbage_time.expired", 'rb')) == FALSE) break; if (($s = fread($fp, 4)) == FALSE) break; @@ -2523,7 +2523,7 @@ class Room { do { if (file_exists(PROXY_PATH) == FALSE) mkdir(PROXY_PATH); - if (($fp = @fopen(PROXY_PATH."/room_garbage_time.expired", 'wb')) == FALSE) + if (($fp = @fopen(PROXY_PATH."/garbage_time.expired", 'wb')) == FALSE) break; fwrite($fp, pack("L",$tm)); fclose($fp); diff --git a/web/briskin5/Obj/briskin5.phh b/web/briskin5/Obj/briskin5.phh index d9427fa..1d8d0d9 100644 --- a/web/briskin5/Obj/briskin5.phh +++ b/web/briskin5/Obj/briskin5.phh @@ -683,7 +683,7 @@ class Bin5 { var $table; var $comm; // commands for many people var $step; // current step of the comm array - var $garbage_timeout; + // externalized var $garbage_timeout; var $shm_sz; var $table_idx; @@ -1145,7 +1145,51 @@ class Bin5 { return ($is_ab); } -} // end class Briskin5 + + + static function garbage_time_is_expired($tm) + { + $ret = TRUE; + $fp = FALSE; + do { + if (file_exists(BIN5_PROXY_PATH) == FALSE) + mkdir(BIN5_PROXY_PATH); + if (($fp = @fopen(BIN5_PROXY_PATH."/garbage_time.expired", 'rb')) == FALSE) + break; + if (($s = fread($fp, 4)) == FALSE) + break; + if (strlen($s) != 4) + break; + $arr = unpack('Le', $s); + if ($arr['e'] > $tm) + $ret = FALSE; + } while (0); + + if ($fp != FALSE) + fclose($fp); + + log_rd2("END: return ".($ret ? "TRUE" : "FALSE")); + + return ($ret); + } + + static function garbage_time_expire_set($tm) + { + do { + if (file_exists(BIN5_PROXY_PATH) == FALSE) + mkdir(BIN5_PROXY_PATH); + if (($fp = @fopen(BIN5_PROXY_PATH."/garbage_time.expired", 'wb')) == FALSE) + break; + fwrite($fp, pack("L",$tm)); + fclose($fp); + + return (TRUE); + } while (0); + + return (FALSE); + } + +} // end class Bin5 function locshm_exists($tok) { -- 2.17.1