pull of unix socket to interact with apache2
[brisk.git] / web / spush / brisk-spush.phh
index 0f22baa..8ff55c1 100644 (file)
@@ -24,7 +24,8 @@
 
 $DOCUMENT_ROOT="";
 $HTTP_HOST="dodo.birds.lan";
-define('USOCK_PATH', "/tmp/brisk.sock");
+define('USOCK_PATH_PFX', "/tmp/brisk");
+define('USOCK_POOL_N', 10);
 
 define('PENDINGPAGE_CONTINUE', 0);
 define('PENDINGPAGE_WAITDATA', 1);
@@ -52,7 +53,7 @@ class PendingPage {
   function PendingPage($socket, $curtime, $kalive)
   {
       $this->socket = $socket;
-      fprintf(STDERR, "SOCKET ADD: %s\n", $this->socket);
+      // fprintf(STDERR, "SOCKET ADD: %s\n", $this->socket);
       $this->kalive = $curtime + $kalive;
   }
 
@@ -81,7 +82,7 @@ class PendingPage {
 
   function to_continuing()
   {
-      printf("TRY FLUSH CREATE\n");
+      // printf("TRY FLUSH CREATE\n");
       $header = array();
       $header['HTTP-Response'] = "100 Continue";
       $hea = headers_render($header, 0);
@@ -136,7 +137,7 @@ class PendingPage {
 
   function to_flushing($enc, &$header_out, $body)
   {
-      printf("TRY FLUSH CREATE: enc[%s]\n", $enc);
+      // printf("TRY FLUSH CREATE: enc[%s]\n", $enc);
       $body_out = ZLibStream::compress($enc, $body);
       if ($enc != 'plain')
           $header_out['Content-Encoding'] = $enc;
@@ -147,26 +148,26 @@ class PendingPage {
       $this->status = PENDINGPAGE_FLUSH;
       $this->msg    = $hea.$body_out;
       $this->msg_sz = $hea_sz + $body_out_sz;
-      printf("TRY FLUSH CREATE: enc[%s]\n", $enc);
+      // printf("TRY FLUSH CREATE: enc[%s]\n", $enc);
   }
 
   /* return TRUE if is removable from it's list */
   function try_flush($curtime)
   {
-      fprintf(STDERR, "IMPORTANT: TRY_FLUSH: start %d\n", $this->status);
+      // fprintf(STDERR, "IMPORTANT: TRY_FLUSH: start %d\n", $this->status);
       if ($this->status != PENDINGPAGE_FLUSH &&
           $this->status != PENDINGPAGE_CONTINUE)
           return (FALSE);
 
       if ($this->kalive < $curtime) {
-          printf("TRY FLUSH CLOSE 1\n");
+          // printf("TRY FLUSH CLOSE 1\n");
           @fclose($this->socket);
           return TRUE;
       }   
 
       $wret = @fwrite($this->socket, $this->msg, mb_strlen($this->msg, "ASCII"));
       if ($wret == FALSE && $wret !== FALSE) {
-          printf("TRY FLUSH PendingPage::try_flush: wret 0 but not FALSE [%d]\n", mb_strlen($this->msg, "ASCII"));
+          // printf("TRY FLUSH PendingPage::try_flush: wret 0 but not FALSE [%d]\n", mb_strlen($this->msg, "ASCII"));
       }
       if ($wret == $this->msg_sz) {
           if ($this->status == PENDINGPAGE_CONTINUE) {
@@ -174,7 +175,7 @@ class PendingPage {
               return FALSE;
           }
           else {
-              printf("TRY FLUSH CLOSE 2\n");
+              // printf("TRY FLUSH CLOSE 2\n");
               fclose($this->socket);
               return TRUE;
           }
@@ -182,7 +183,7 @@ class PendingPage {
       $this->msg_sz -= $wret;
       $this->msg    = mb_substr($this->msg, $wret, $this->msg_sz, "ASCII");
 
-      printf("TRY FLUSH RETURN FALSE\n");
+      // printf("TRY FLUSH RETURN FALSE\n");
 
       return FALSE;
   }