proxy step paradigm changed from set and get to load and save sincronously with load...
authorMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Wed, 30 Mar 2011 16:44:17 +0000 (18:44 +0200)
committerMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Wed, 30 Mar 2011 16:44:17 +0000 (18:44 +0200)
web/Obj/brisk.phh
web/briskin5/Obj/briskin5.phh

index ca9a140..ecee1af 100644 (file)
@@ -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);
index dc1e055..2995972 100644 (file)
@@ -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) 
     {