Skip to content
This repository has been archived by the owner on Aug 25, 2022. It is now read-only.

readBytes fix-read-endless-loop #196

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/Engine/AbstractSocketIO.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,15 @@ protected function readBytes($bytes)
$data = '';
$chunk = null;
while ($bytes > 0 && false !== ($chunk = \fread($this->stream, $bytes))) {
// if endless loop, break
if (strlen($chunk) == 0) {
yufewell marked this conversation as resolved.
Show resolved Hide resolved
$stream = stream_get_meta_data($this->stream);

if (isset($stream['timed_out']) && $stream['timed_out'] == true) {
yufewell marked this conversation as resolved.
Show resolved Hide resolved
break;
}
}

$bytes -= \strlen($chunk);
$data .= $chunk;
}
Expand Down