[RCU] How to configure timeout on external http calls

A.L.E.C alec at alec.pl
Mon Jul 9 10:03:48 CEST 2012


On 07/09/2012 07:17 AM, Krishna PMV wrote:
> Ok, it turns out to be a bug in roundcube here:
> https://svn.roundcube.net/trunk/roundcubemail/program/steps/utils/modcss.inc
> 
> Its neatly explained here:
> http://in2.php.net/manual/en/function.stream-set-timeout.php#71274

I think there was a similiar issue in IMAP connections handling. Please,
try with this patch.

--- program/steps/utils/modcss.inc
+++ program/steps/utils/modcss.inc
@@ -59,7 +59,7 @@ fwrite($fp, $out);
 // read response
 $header = true;
 $headers = array();
-while (!feof($fp)) {
+while (!socket_eof($fp)) {
     $line = trim(fgets($fp, 4048));

     if ($header) {
@@ -96,3 +96,19 @@ echo $error;
 exit;


+function socket_eof($fp)
+{
+    if (!is_resource($fp)) {
+        return true;
+    }
+
+    // If a connection opened by fsockopen() wasn't closed
+    // by the server, feof() will hang.
+    $start = microtime(true);
+
+    if (feof($fp) || microtime(true) - $start > 30) {
+        return true;
+    }
+
+    return false;
+}


-- 
Aleksander 'A.L.E.C' Machniak
LAN Management System Developer [http://lms.org.pl]
Roundcube Webmail Developer  [http://roundcube.net]
---------------------------------------------------
PGP: 19359DC1 @@ GG: 2275252 @@ WWW: http://alec.pl


More information about the users mailing list