changed how configs work
[CBFWR.git] / libcbfwr / comms.php
index a11f9b3..b0c4f04 100644 (file)
@@ -1,11 +1,12 @@
 <?php
 // C = msg key
 // L = locking key
-$MESSAGE_KEY = ftok(realpath(dirname(__FILE__)), "c");
+$MESSAGE_KEY = ftok(realpath(dirname(__FILE__)), "c"); // to daemon
 $LOCKING_KEY = ftok(realpath(dirname(__FILE__)), "l");
 $STORE_KEY = ftok(realpath(dirname(__FILE__)), "s");
+$CONF_STORE_SIZE = 16777216; // 16M by default
 
-global $MESSAGE_KEY, $LOCKING_KEY, $STORE_KEY;
+global $MESSAGE_KEY, $LOCKING_KEY, $STORE_KEY, $CONF_STORE_SIZE;
 
 class Comms {
        function __construct()
@@ -17,9 +18,9 @@ class Comms {
        
        function getConfig($type=0)
        {
-               global $MESSAGE_KEY, $LOCKING_KEY, $STORE_KEY;
+               global $MESSAGE_KEY, $LOCKING_KEY, $STORE_KEY, $CONF_STORE_SIZE;
                sem_acquire($this->semres);
-               $shm_space = shm_attach($STORE_KEY, 16*1024*1024);
+               $shm_space = shm_attach($STORE_KEY, $CONF_STORE_SIZE);
                $config = shm_get_var($shm_space, $type);
                sem_release($this->semres);
                
@@ -43,9 +44,9 @@ class Comms {
        // type = 3 for web config
        function putConfig($config, $type=0)
        {
-               global $MESSAGE_KEY, $LOCKING_KEY, $STORE_KEY;
+               global $MESSAGE_KEY, $LOCKING_KEY, $STORE_KEY, $CONF_STORE_SIZE;
                sem_acquire($this->semres);
-               $shm_space = shm_attach($STORE_KEY, 16*1024*1024);
+               $shm_space = shm_attach($STORE_KEY, $CONF_STORE_SIZE);
                shm_put_var($shm_space, $type, $config);
                sem_release($this->semres);             
        }