Обновил движок своего чата (https://schat[dot]org[dot]ua/ ) используя исходники с хабра [url]https://habrahabr[dot]ru/company/ifree/blog/210228/ [/url] некоторое время работало нормально но начало виснуть по непонятной причине, в логах пишет следующее предупреждение:
stream_select(): supplied argument is not a valid stream resource in /www/schat.org.ua/chat/server/We bsocketGeneric.php on line 70
И чат начинает виснуть. Часть кода:
PHP:
скопировать код в буфер обмена
скопировать код в буфер обмена
- const MAX_SOCKETS = 1000;
- const SOCKET_MESSAGE_DELIMITER = "\n";
- protected $_server = null;
- protected $_service = null;
- protected $_master = null;
- public $timer = null;
- public $parVal = 0;
- public $parLog = 0;
- public function start() {
- $this->onStart();
- if ($this->timer) {
- $timer = $this->_createTimer();
- }
- while (true) {
- //if($this->parVal+5 < $tmp && $this->parVal > 0){
- if($this->parVal != 0 && $this->parVal+100 < $tmp){
- $this->Strt($tmp);
- $this->parVal = $tmp;
- }
- if($this->parLog != 0 && $this->parLog+30 < $tmp){
- $this->GetAllLog();
- $this->parLog = $tmp;
- }
- //подготавливаем массив всех сокетов, которые нужно обработать
- $read = $this->clients + $this->services;
- if ($this->_server) {
- $read[] = $this->_server;
- }
- if ($this->_service) {
- $read[] = $this->_service;
- }
- if ($this->_master) {
- $read[] = $this->_master;
- }
- if ($this->timer) {
- $read[] = $timer;
- }
- if (!$read) {
- //if (strlen($read)) {
- return;
- }
- if ($this->_write) {
- foreach ($this->_write as $connectionId => $buffer) {
- if ($buffer) {//var_export($buffer);
- $write[] = $this->getConnectionById($connectionId);
- }
- }
- }
- $except = $read;