Code

Fixed socket timeout
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 21 Jan 2008 10:47:33 +0000 (10:47 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 21 Jan 2008 10:47:33 +0000 (10:47 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8515 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_socketClient.inc

index 0ed42a5fa3fda35febbf76d423f71a1e342b5f34..7f571a31e89f69683fca82566f2a72d90231bef5 100644 (file)
@@ -117,14 +117,16 @@ class Socket_Client
                        $read = array("0"=>$this->handle);
                        $write = array();
                        $accept = array();      
-                       $num = @stream_select($read,$write,$accept,floor($this->timeout), ceil($this->timeout*1000000));
+                       $start = microtime();           
+                       $num = @stream_select($read,$write,$accept,floor($this->timeout), ceil($this->timeout*100000));
                        $str = "";              
-               
+                       socket_set_timeout($this->handle,$this->timeout);                       
+
                        /* Read data if necessary */
-                       while($num && $this->b_data_send){
-                               $str.= fread($this->handle, 1024000);
+                       while($num && get_MicroTimeDiff($start,microtime()) < $this->timeout){
+                               $str.= fread($this->handle, 100);
                                $read = array("0"=>$this->handle);      
-                               $num = @stream_select($read,$write,$accept,floor($this->timeout), ceil($this->timeout*1000000));
+                               $num = @stream_select($read,$write,$accept,floor($this->timeout), ceil($this->timeout*100000));
                        }
                        $this->bytes_read = strlen($str);
                        $this->b_data_send = FALSE;