Fix for endless loop when client disconnects
This commit is contained in:
parent
3da01d5897
commit
aa4bafc391
@ -131,6 +131,11 @@ class Server extends Command
|
|||||||
// Read a character from the client session
|
// Read a character from the client session
|
||||||
$read = $client->read(1);
|
$read = $client->read(1);
|
||||||
|
|
||||||
|
// It appears that read will return '' instead of false when a disconnect has occurred.
|
||||||
|
// We'll set it to NULL so its caught later
|
||||||
|
if ($read === '')
|
||||||
|
$read = NULL;
|
||||||
|
|
||||||
if ($read != '') {
|
if ($read != '') {
|
||||||
dump(sprintf('Mode: [%s] CMD: [%s] frame: [%s] Received [%s (%s)]', $mode, $cmd, $page['frame'].$page['index'], $read, ord($read)));
|
dump(sprintf('Mode: [%s] CMD: [%s] frame: [%s] Received [%s (%s)]', $mode, $cmd, $page['frame'].$page['index'], $read, ord($read)));
|
||||||
|
|
||||||
@ -783,7 +788,8 @@ class Server extends Command
|
|||||||
|
|
||||||
// Did the client disconnect
|
// Did the client disconnect
|
||||||
if ($read === NULL || socket_last_error()) {
|
if ($read === NULL || socket_last_error()) {
|
||||||
Log::debug('Disconnected: '.$client->getaddress());
|
$client->close();
|
||||||
|
Log::debug('Client Disconnected: '.$client->getaddress());
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user