Code

Updated socket client
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 23 Jan 2008 08:50:19 +0000 (08:50 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 23 Jan 2008 08:50:19 +0000 (08:50 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8546 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_socketClient.inc

index eefff1b7bd11b6df0e415b69af76d9a85be27b3c..75f97582845341c587ef9725a912a3e185a0e113 100644 (file)
@@ -107,6 +107,17 @@ class Socket_Client
                return $this->b_data_send;
        }
 
+       
+       private _is_timeout($start,$stop = microtime())
+       {
+               $a = split("\ ",$start);
+               $b = split("\ ",$stop);
+               $secs = $b[1] - $a[1];
+               $msecs= $b[0] - $a[0];
+               $ret = (float) ($secs+ $msecs);
+               return($ret => $this->timeout);
+       }
+
 
        public function read()
        {
@@ -117,7 +128,7 @@ class Socket_Client
                stream_set_blocking($this->handle,0);
                $start = microtime();
 
-               while(strlen($str) == 0 || get_MicroTimeDiff($start,microtime()) < $this->timeout) {
+               while(strlen($str) == 0 || !$this->_is_timeout($start)) {
                        usleep(10000);
                        $data = fread($this->handle, 1024000);
                        if($data && strlen($data)>0) {
@@ -126,8 +137,8 @@ class Socket_Client
                                break;
                        }
                }
-               if(get_MicroTimeDiff($start,microtime()) >= $this->timeout){
-                       trigger_error(sprintf("Exceeded timeout %f while reading from socket. Time spend for reading was %f.",$this->timeout,get_MicroTimeDiff($start,microtime())));
+               if($this->_is_timeout($start)){
+                       trigger_error(sprintf("Exceeded timeout %f while reading from socket",$this->timeout));
                }
                $this->bytes_read = strlen($str);
                $this->b_data_send = FALSE;