log_shme() function added and DBG_SHME flag
authorMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Wed, 18 May 2011 21:17:52 +0000 (23:17 +0200)
committerMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Wed, 18 May 2011 21:17:52 +0000 (23:17 +0200)
INSTALL.sh
doc/ARCHITECTURE.txt
web/Obj/auth.phh
web/Obj/brisk.phh
web/Obj/hardban.phh
web/briskin5/Obj/briskin5.phh

index e2f2b51..6437212 100755 (executable)
@@ -251,7 +251,7 @@ if [ "$web_only" = "FALSE" ]; then
         chmod 777 ${ftokk_path}/bin5
     fi
 
-    for i in $(seq 0 $max_players); do
+    for i in $(seq 0 $((tables_n - 1))); do
         if [ ! -d ${ftokk_path}/bin5/table$i ]; then
             mkdir ${ftokk_path}/bin5/table$i
         fi
@@ -262,13 +262,13 @@ if [ "$web_only" = "FALSE" ]; then
             touch ${ftokk_path}/bin5/table$i/user$e
             chmod 666 ${ftokk_path}/bin5/table$i/user$e
         done
+        # create subdirectories in proxy path
+        if [ ! -d ${proxy_path}/bin5/table$i ]; then
+            mkdir -p ${proxy_path}/bin5/table$i
+        fi
     done
+    chmod -R 777 ${proxy_path}/bin5
 
-    # create subdirectories in proxy path
-    if [ ! -d ${proxy_path}/bin5 ]; then
-        mkdir ${proxy_path}/bin5
-    fi
-    chmod 777 ${proxy_path}/bin5
 fi
 install -d ${web_path}__
 for i in $(find web -type d | grep -v /CVS | sed 's/^....//g'); do
index 807c5fb..cbb47c8 100644 (file)
@@ -28,3 +28,9 @@ index.php:
                    window.onunload = null; document.location.assign("../index.php");" 
        in user->comm var for client xhr
      - set $bri->the_end = TRUE
+
+
+-> index.php  (after verify session value: ~L250)
+  - garbage_manager(TRUE)
+    - allign many status var with briskin5 user values
+    - room_join_wakeup()
index 11c7425..0615388 100644 (file)
@@ -191,6 +191,7 @@ class Challenges {
                             log_only("PUT_VAR FALLITA ".strlen(serialize($chals)));
                             log_only(serialize($chals));
                         }
+                        log_shme("Challenges::save_data2");
                     }
                     $chals->shm_sz = $shm_sz;
        
@@ -222,7 +223,8 @@ class Challenges {
                 log_only("challenges count ".count($chals->item)."  _n: ".$chals->item_n);
 
             $chals->mod = FALSE;
-            if (shm_put_var($shm, $tok, $chals) != FALSE) {
+            if (@shm_put_var($shm, $tok, $chals) != FALSE) {
+                log_shme("Challenges::save_data");
                 shm_detach($shm);
                 return (TRUE);
             }
index 2ba7c1a..38bc1cf 100644 (file)
@@ -71,6 +71,7 @@ define(DBG_AUTH, 0x0200);
 define(DBG_CRIT, 0x0400);
 define(DBG_LMOP, 0x0800);
 define(DBG_TRAC, 0x1000);
+define(DBG_SHME, 0x2000);
 // NOTE: BRISK DEBUG must be a numerical constant, not the result of operations on symbols 
 define(BRISK_DEBUG, 0xffffffbf);
 
@@ -945,6 +946,7 @@ class User {
                       log_only("PUT_VAR FALLITA ".strlen(serialize($user)));
                       log_only(serialize($user));
                   }
+                  log_shme("User::save_data2");
               }
               else {
                   if ($sess != FALSE) {
@@ -989,10 +991,13 @@ class User {
               break;
           
           // log_only("PUT_VAR DI ".strlen(serialize($user)));
-          if (shm_put_var($shm, $tok, $user) != FALSE) {
+          if (@shm_put_var($shm, $tok, $user) != FALSE) {
               shm_detach($shm);
               if ($user->sess != "")
                   $user->save_step();
+
+              log_shme("User::save_data");
+
               log_main("User[".$id."] saved.");
               return (TRUE);
           }
@@ -2280,6 +2285,8 @@ class Room {
               
               $room = Room::create();
               
+              log_shme("Room::create");
+
               if (Room::save_data($room) == FALSE)
                   return FALSE;
 
@@ -2326,7 +2333,7 @@ class Room {
        break;
       
       // log_only("PUT_VAR DI ".strlen(serialize($room)));
-      if (shm_put_var($shm, $tok, $room) != FALSE) {
+      if (@shm_put_var($shm, $tok, $room) != FALSE) {
        shm_detach($shm);
        return (TRUE);
       }
@@ -2368,7 +2375,8 @@ class Room {
               break;
       
           // log_only("PUT_VAR DI ".strlen(serialize($room)));
-          if (shm_put_var($shm, $tok, $room) != FALSE) {
+          if (@shm_put_var($shm, $tok, $room) != FALSE) {
+              log_shme("Room::save_data");
               $ret = TRUE;
               break;
           }
@@ -2865,6 +2873,32 @@ function log_auth($sess, $log)
     }
 }
 
+function log_shme($log)
+{
+    GLOBAL $sess, $PHP_SELF;
+    
+    if (BRISK_SINGLE_SESS == "" && (BRISK_DEBUG & DBG_SHME) == 0)
+        return;
+    
+    if (isset($sess) == FALSE)
+        $ssess = "XXXX";
+    else
+        $ssess = $sess;
+    
+    if (( (BRISK_DEBUG | ($ssess == BRISK_SINGLE_SESS ? BRISK_SINGLE_DEBUG : 0) ) & DBG_SHME) == 0)
+        return;
+    
+    if (BRISK_DEBUG & DBG_TRAC) 
+        $btrace = btrace_line(debug_backtrace());
+    else
+        $btrace = "";
+    if (($fp = @fopen(LEGAL_PATH."/brisk.log", 'a')) != FALSE) {
+        fwrite($fp, sprintf("SHME: [%s] [%s] [%s]\n", $ssess, $log, $btrace));
+        fclose($fp);
+    }
+}
+
+
 
 // function log_legal($curtime, $sess, $name, $where, $mesg) 
 function log_legal($curtime, $user, $where, $mesg) 
index 7423b6a..e26fc4c 100644 (file)
@@ -184,6 +184,8 @@ class Hardbans {
            log_only("PUT_VAR FALLITA ".strlen(serialize($hban)));
            log_only(serialize($hban));
          }
+          log_shme("Hardban::save_data2");
+
        }
        $hban->shm_sz = $shm_sz;
        
@@ -215,8 +217,9 @@ class Hardbans {
         log_only("hardban count ".count($hban->item)."  _n: ".$hban->item_n);
 
       $hban->mod = FALSE;
-      if (shm_put_var($shm, $tok, $hban) != FALSE) {
+      if (@shm_put_var($shm, $tok, $hban) != FALSE) {
        shm_detach($shm);
+        log_shme("Hardban::save_data");
        return (TRUE);
       }
       $hban->mod = $oldmod;
index 164fb50..ce2bdb8 100644 (file)
@@ -604,6 +604,8 @@ class Bin5_user extends User {
                     // SHSPLIT FIXME: init_data for User class ??
                     $user = User::create($id, "", "");
                     if (@shm_put_var($shm, $tok, $user) == FALSE) {
+                        log_shme("Bin5_user::save_data2");
+
                         log_only("PUT_VAR FALLITA ".strlen(serialize($user)));
                         log_only(serialize($user));
                     }
@@ -652,10 +654,13 @@ class Bin5_user extends User {
               break;
           
           // log_only("PUT_VAR DI ".strlen(serialize($user)));
-          if (shm_put_var($shm, $tok, $user) != FALSE) {
+          if (@shm_put_var($shm, $tok, $user) != FALSE) {
               shm_detach($shm);
               $user->save_step();
               log_main("User[".$id."] saved.");
+
+              log_shme("Bin5_user::save_data");
+
               return (TRUE);
           }
           if (shm_remove($shm) === FALSE) {
@@ -882,6 +887,9 @@ class Bin5 {
               break;
           
           if (@shm_put_var($shm, $bri->tok, $bri) != FALSE) {
+
+              log_shme("Bin5::save_data");
+
               $ret = TRUE;
               break;
           }