diff options
author | Andreas Gohr <andi@splitbrain.org> | 2012-11-30 12:30:40 +0100 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2012-11-30 12:30:40 +0100 |
commit | d14415e37072dbe16077efd700aee5bd33707b54 (patch) | |
tree | 062c3c190039ac9490f56598b0ee116de18c2480 /inc/HTTPClient.php | |
parent | 2ed38036a53a489d2fcadc46ce601f8c876fca31 (diff) | |
parent | 38479cbba628ee76a92ff5f3c974cfa8e6ce9e61 (diff) | |
download | rpg-d14415e37072dbe16077efd700aee5bd33707b54.tar.gz rpg-d14415e37072dbe16077efd700aee5bd33707b54.tar.bz2 |
Merge branch 'master' into subscription
* master: (175 commits)
some coding style improvements
added .idea project folder to gitignore
use correct setUp method and parent calls.
Correct German plugin manager translation (download != install)
correct return in sendDigest()
Fix case-insensitive match in ACL checking
GeSHi update to 1.0.8.11
ignore empty header on mail sending
remove empty BCC/CC mail headers
Galician language update
some welcome page changes
Combine subsequent calls to strtr into a single transformation
changed semicolon to colon in link to welcome page to make it less confusing
fixed wrong sidebar showing in namespaces when sidebar is disabled
Typo fix for TL;DR
removed a bunch of outdated and irrelevant networking acronyms
added another place to look for logo to make it more consistent (FS#2656)
French language update
Czech language update
compat js findPosX/y more closely mimic historical function
...
Conflicts:
inc/auth.php
inc/common.php
inc/subscription.php
lib/exe/indexer.php
Diffstat (limited to 'inc/HTTPClient.php')
-rw-r--r-- | inc/HTTPClient.php | 54 |
1 files changed, 26 insertions, 28 deletions
diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php index a25846c31..c4cfcbf7c 100644 --- a/inc/HTTPClient.php +++ b/inc/HTTPClient.php @@ -509,15 +509,17 @@ class HTTPClient { if(feof($socket)) throw new HTTPClientException("Socket disconnected while writing $message"); - // wait for stream ready or timeout - self::selecttimeout($this->timeout - $time_used, $sec, $usec); - if(@stream_select($sel_r, $sel_w, $sel_e, $sec, $usec) !== false){ - // write to stream - $nbytes = fwrite($socket, substr($data,$written,4096)); - if($nbytes === false) - throw new HTTPClientException("Failed writing to socket while sending $message", -100); - $written += $nbytes; + // wait for stream ready or timeout (1sec) + if(@stream_select($sel_r,$sel_w,$sel_e,1) === false){ + usleep(1000); + continue; } + + // write to stream + $nbytes = fwrite($socket, substr($data,$written,4096)); + if($nbytes === false) + throw new HTTPClientException("Failed writing to socket while sending $message", -100); + $written += $nbytes; } } @@ -556,15 +558,17 @@ class HTTPClient { } if ($to_read > 0) { - // wait for stream ready or timeout - self::selecttimeout($this->timeout - $time_used, $sec, $usec); - if(@stream_select($sel_r, $sel_w, $sel_e, $sec, $usec) !== false){ - $bytes = fread($socket, $to_read); - if($bytes === false) - throw new HTTPClientException("Failed reading from socket while reading $message", -100); - $r_data .= $bytes; - $to_read -= strlen($bytes); + // wait for stream ready or timeout (1sec) + if(@stream_select($sel_r,$sel_w,$sel_e,1) === false){ + usleep(1000); + continue; } + + $bytes = fread($socket, $to_read); + if($bytes === false) + throw new HTTPClientException("Failed reading from socket while reading $message", -100); + $r_data .= $bytes; + $to_read -= strlen($bytes); } } while ($to_read > 0 && strlen($r_data) < $nbytes); return $r_data; @@ -595,11 +599,13 @@ class HTTPClient { if(feof($socket)) throw new HTTPClientException("Premature End of File (socket) while reading $message"); - // wait for stream ready or timeout - self::selecttimeout($this->timeout - $time_used, $sec, $usec); - if(@stream_select($sel_r, $sel_w, $sel_e, $sec, $usec) !== false){ - $r_data = fgets($socket, 1024); + // wait for stream ready or timeout (1sec) + if(@stream_select($sel_r,$sel_w,$sel_e,1) === false){ + usleep(1000); + continue; } + + $r_data = fgets($socket, 1024); } while (!preg_match('/\n$/',$r_data)); return $r_data; } @@ -630,14 +636,6 @@ class HTTPClient { } /** - * Calculate seconds and microseconds - */ - static function selecttimeout($time, &$sec, &$usec){ - $sec = floor($time); - $usec = (int)(($time - $sec) * 1000000); - } - - /** * convert given header string to Header array * * All Keys are lowercased. |