A few miscellaneous fixes including modifying WebServer to write data in chunks (improved performance and reliability on a slow connection)
authorDan
Tue, 23 Dec 2008 20:20:35 -0500
changeset 64 ee64bb096f56
parent 63 af239423ed15
child 65 35fe20340c91
A few miscellaneous fixes including modifying WebServer to write data in chunks (improved performance and reliability on a slow connection)
functions.php
greyhound.php
uiconfig.php
webserver.php
--- a/functions.php	Tue Dec 23 17:37:51 2008 -0500
+++ b/functions.php	Tue Dec 23 20:20:35 2008 -0500
@@ -290,9 +290,13 @@
     // separate from the default)
     
     if ( @is_dir(GREY_ROOT . '/.hg') )
+    {
       require(GREY_ROOT . '/config.dev.php');
+    }
     else
+    {
       require(GREY_ROOT . '/config.php');
+    }
   }
   
   foreach ( array('public', 'enable_ipv4', 'enable_ipv6', 'allowcontrol', 'theme', 'allow_fork', 'use_auth', 'auth_data', 'configpass') as $var )
--- a/greyhound.php	Tue Dec 23 17:37:51 2008 -0500
+++ b/greyhound.php	Tue Dec 23 20:20:35 2008 -0500
@@ -34,7 +34,7 @@
 define('GREY_ROOT', dirname(__FILE__));
 
 // what kind of terminal do we have?
-$use_colors = ( @in_array(@$_SERVER['TERM'], array('linux', 'xterm', 'vt100')) ) ? true : false;
+$use_colors = ( @in_array(@$_SERVER['TERM'], array('linux', 'xterm', 'vt100', 'screen')) ) ? true : false;
 require(GREY_ROOT . '/functions.php');
 
 // start up...
--- a/uiconfig.php	Tue Dec 23 17:37:51 2008 -0500
+++ b/uiconfig.php	Tue Dec 23 20:20:35 2008 -0500
@@ -85,7 +85,7 @@
     }
     $auth_data = var_export_string($auth_data);
     
-    $new_configpass = ( is_string($_POST['newconfigpass']) && $_POST['newconfigpass'] != '____________________' ) ? sha1($_POST['newconfigpass']) : $GLOBALS['configpass'];
+    $new_configpass = ( isset($_POST['configpass']) && is_string($_POST['newconfigpass']) && $_POST['newconfigpass'] != '____________________' ) ? sha1($_POST['newconfigpass']) : $GLOBALS['configpass'];
     
     $config_file = <<<EOF
 <?php
--- a/webserver.php	Tue Dec 23 17:37:51 2008 -0500
+++ b/webserver.php	Tue Dec 23 20:20:35 2008 -0500
@@ -265,7 +265,7 @@
         if ( is_string($targetgroup) )
         {
           $targetgroup = posix_getgrnam($targetgroup);
-          $targetgroup = $targetgroup['uid'];
+          $targetgroup = $targetgroup['gid'];
         }
         // make sure all info is valid
         if ( !is_int($targetuser) || !is_int($targetgroup) )
@@ -624,6 +624,10 @@
         if ( preg_match('/^HTTP_/', $key) )
           unset($_SERVER[$key]);
       }
+      if ( !isset($_SERVER['SERVER_SOFTWARE']) )
+      {
+        $_SERVER['SERVER_SOFTWARE'] =& $this->server_string;
+      }
       unset($client_headers[0]);
       foreach ( $client_headers as $line )
       {
@@ -2126,7 +2130,15 @@
   
   function write($data)
   {
-    return @fwrite($this->sock, $data);
+    $data = str_split($data, 8096);
+    foreach ( $data as $chunk )
+    {
+      while ( !@fwrite($this->sock, $chunk) )
+      {
+        usleep(50000);
+      }
+    }
+    return true;
   }
   
   function is_eof()