Code

Simplified the sieve class error retrieve method.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 13 Mar 2007 07:07:23 +0000 (07:07 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 13 Mar 2007 07:07:23 +0000 (07:07 +0000)
Sometimes, the calculation was wrong and caused the ui to freeze for
'socket.timeout' seconds.

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@5770 594d385d-05f5-0310-b6e9-bd551577e9d8

include/sieve/class_sieve.inc
include/sieve/class_sieveManagement.inc

index c16345f2b394285b1d930a4d607ba325ad49e330..84940955e92e60790adfb070055eb8d3bf0104c9 100644 (file)
@@ -114,31 +114,22 @@ class sieve
                                $this->err_len = substr($this->mtoken, 1, $this->x);
                                $this->x++;    
                        }
-                       //print "<br>Trying to receive $this->err_len bytes for result<br>";
+                       #print "<br>Trying to receive $this->err_len bytes for result<br>";
                        $this->line = fgets($this->fp,$this->err_len);
                        $this->error_raw[]=substr($this->line, 0, strlen($this->line) -2);    //we want to be nice and strip crlf's
                        $this->err_recv = strlen($this->line);
 
-                       $last_cnt_to_fetch = -1;
-                       while($this->err_recv < ($this->err_len)){
-
-                               /* We are trying to read the same count of chars 
-                 *  as we tried last while loop. 
-                                * There must be something wrong-
-                 */
-                               if($last_cnt_to_fetch   == ($this->err_len-$this->err_recv)){
-                                       $cur = $max;
-                                       echo "Sieve : failed to read error msgs, .. skipped endless loop! ~class_sieve.inc 525";
-                               }
-                               $last_cnt_to_fetch = $this->err_len-$this->err_recv;
-                               $this->line = fgets($this->fp);//, ($this->err_len-$this->err_recv));
-                               $this->error_raw[]=substr($this->line, 0, strlen($this->line) -2);    //we want to be nice and strip crlf's
-                               $this->err_recv += strlen($this->line);
-                       } /* end while */
+                       /* Ensure max loop of 1000, to keep the ui from freezing */
+                       $max = 1000;
+                       $cur = 0;
 
-                       $this->line = fgets($this->fp, 1024);   //we need to grab the last crlf, i think.  this may be a bug...
-                       $this->error=EC_UNKNOWN;
+                       while($this->err_recv < ($this->err_len) && ($cur < $max)){
 
+                               $cur ++;
+                               $this->line      = fgets($this->fp,4096);
+                               $this->err_recv += strlen($this->line);
+                               $this->error_raw[]=preg_replace("/\r\n/","",$this->line);    //we want to be nice and strip crlf'
+                       } 
                } /* end if */
                elseif($this->mtoken[0] == "("){
                        switch($this->mtoken){
index ea355b2e3937a2c08108555cc388d385942807ab..da36074a0e57c9a711ca25d8d360560eafe0f3fd 100644 (file)
@@ -308,6 +308,7 @@ class sieveManagement extends plugin
                                            _("Failed to save sieve script").": ".
                                            to_string($this->sieve_handle->error_raw).
                                            "</font>";
+#          echo nl2br($data);
         }
       }
     }