Skip to content

Commit

Permalink
Fixed buzy loop (temporary fix for duoshuo#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-lb committed May 29, 2015
1 parent 701576b commit b6444ee
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Connection/Socket.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function getOptions() {
public function read($length) {
$data = socket_read($this->_socket, $length);

if ($data === false){
if ($data === false || ($length > 0 && $data === '')){
$errorCode = socket_last_error($this->_socket);
throw new SocketException(socket_strerror($errorCode), $errorCode);
}
Expand All @@ -89,7 +89,7 @@ public function read($length) {
while($remainder > 0) {
$readData = socket_read($this->_socket, $remainder);

if ($readData === false){
if ($readData === false || ($remainder > 0 && $readData === '')){
$errorCode = socket_last_error($this->_socket);
throw new SocketException(socket_strerror($errorCode), $errorCode);
}
Expand Down

0 comments on commit b6444ee

Please sign in to comment.