From e85c7217ac848be97c48bb14ddc2858289fbf34a Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Wed, 30 Mar 2011 18:44:17 +0200 Subject: [PATCH] proxy step paradigm changed from set and get to load and save sincronously with load and save user data --- web/Obj/brisk.phh | 52 ++++++++++++++++++-------------- web/briskin5/Obj/briskin5.phh | 56 ++++++++++++++++------------------- 2 files changed, 54 insertions(+), 54 deletions(-) diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index ca9a140..ecee1af 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -814,6 +814,19 @@ class User { { $this->step = $step & 0x7fffffff; + return (TRUE); + } + + function step_inc($delta = 1) { + $this->step += $delta; + /* modularization because unpack() not manage unsigned 32bit int correctly */ + $this->step &= 0x7fffffff; + + return TRUE; + } + + function save_step() + { do { if (validate_sess($this->sess) == FALSE) break; @@ -823,7 +836,7 @@ class User { break; fwrite($fp, pack("LL",$this->step, $this->idx)); fclose($fp); - + log_main("step_set [".$this->sess. "] [".$this->step."]"); return (TRUE); @@ -832,27 +845,7 @@ class User { return (FALSE); } - function step_inc($delta = 1) { - $this->step += $delta; - /* modularization because unpack() not manage unsigned 32bit int correctly */ - $this->step &= 0x7fffffff; - - if (validate_sess($this->sess)) { - if (file_exists(PROXY_PATH) == FALSE) - mkdir(PROXY_PATH); - $fp = fopen(PROXY_PATH."/".$this->sess.".step", 'w'); - fwrite($fp, pack("LL", $this->step, $this->idx)); - fclose($fp); - - log_main("step_inc [".$this->sess. "] [".$this->step."]"); - - return (TRUE); - } - - return (FALSE); - } - - static function step_get($sess) + static function load_step($sess) { $fp = FALSE; do { @@ -938,7 +931,20 @@ class User { log_only(serialize($user)); } } - + else { + if ($sess != FALSE) { + /* + * NOTE: this part is for check only, theoretically + * user->step anch proxy_step are set allways at the same value + */ + $old_step = $user->step; + $arr = User::load_step($sess); + $user->step = $arr['s']; + if ($old_step != $user->step) { + log_crit("steps are diffetents User->step ".$user->step." Old_step: ".$old_step); + } + } + } $user->shm_sz = $shm_sz; shm_detach($shm); diff --git a/web/briskin5/Obj/briskin5.phh b/web/briskin5/Obj/briskin5.phh index dc1e055..2995972 100644 --- a/web/briskin5/Obj/briskin5.phh +++ b/web/briskin5/Obj/briskin5.phh @@ -509,22 +509,7 @@ class Bin5_user extends User { { $this->step = $step & 0x7fffffff; - do { - if (validate_sess($this->sess) == FALSE) - break; - if (file_exists(BIN5_PROXY_PATH) == FALSE) - mkdir(BIN5_PROXY_PATH, 0775, TRUE); - if (($fp = @fopen(BIN5_PROXY_PATH."/".$this->sess.".step", 'w')) == FALSE) - break; - fwrite($fp, pack("LL",$this->step, $this->idx)); - fclose($fp); - - log_main("step_set [".$this->sess. "] [".$this->step."]"); - - return (TRUE); - } while (0); - - return (FALSE); + return TRUE; } function step_inc($delta = 1) { @@ -532,22 +517,10 @@ class Bin5_user extends User { /* modularization because unpack() not manage unsigned 32bit int correctly */ $this->step &= 0x7fffffff; - if (validate_sess($this->sess)) { - if (file_exists(BIN5_PROXY_PATH) == FALSE) - mkdir(BIN5_PROXY_PATH); - $fp = fopen(BIN5_PROXY_PATH."/".$this->sess.".step", 'w'); - fwrite($fp, pack("LL", $this->step, $this->idx)); - fclose($fp); - - log_main("step_inc [".$this->sess. "] [".$this->step."]"); - - return (TRUE); - } - - return (FALSE); + return (TRUE); } - - static function step_get($sess) + + static function load_step($sess) { $fp = FALSE; do { @@ -576,6 +549,27 @@ class Bin5_user extends User { return (FALSE); } + + function save_step() + { + do { + if (validate_sess($this->sess) == FALSE) + break; + if (file_exists(BIN5_PROXY_PATH) == FALSE) + mkdir(BIN5_PROXY_PATH, 0775, TRUE); + if (($fp = @fopen(BIN5_PROXY_PATH."/".$this->sess.".step", 'w')) == FALSE) + break; + fwrite($fp, pack("LL",$this->step, $this->idx)); + fclose($fp); + + log_main("step_set [".$this->sess. "] [".$this->step."]"); + + return (TRUE); + } while (0); + + return (FALSE); + } + static function load_data($tab_id, $id, $sess) { -- 2.17.1