Skip to content

Commit

Permalink
Update Gateway.php
Browse files Browse the repository at this point in the history
  • Loading branch information
walkor authored May 22, 2018
1 parent 7ec9569 commit 25b960f
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Gateway extends Worker
*
* @var string
*/
const VERSION = '3.0.9';
const VERSION = '3.1.0';

/**
* 本机 IP
Expand Down Expand Up @@ -378,7 +378,7 @@ protected function sendToWorker($cmd, $connection, $body = '')
$worker_connection = call_user_func($this->router, $this->_workerConnections, $connection, $cmd, $body);
if (false === $worker_connection->send($gateway_data)) {
$msg = "SendBufferToWorker fail. May be the send buffer are overflow. See http://wiki.workerman.net/Error2";
$this->log($msg);
static::log($msg);
return false;
}
} // 没有可用的 worker
Expand All @@ -388,7 +388,7 @@ protected function sendToWorker($cmd, $connection, $body = '')
$time_diff = 2;
if (time() - $this->_startTime >= $time_diff) {
$msg = 'SendBufferToWorker fail. The connections between Gateway and BusinessWorker are not ready. See http://wiki.workerman.net/Error3';
$this->log($msg);
static::log($msg);
}
$connection->destroy();
return false;
Expand Down Expand Up @@ -897,7 +897,6 @@ public function onWorkerMessage($connection, $data)
*/
public function onWorkerClose($connection)
{
// $this->log("{$connection->key} CLOSE INNER_CONNECTION\n");
if (isset($connection->key)) {
unset($this->_workerConnections[$connection->key]);
}
Expand Down Expand Up @@ -1005,4 +1004,14 @@ public function onWorkerStop()
call_user_func($this->_onWorkerStop, $this);
}
}

/**
* Log.
* @param string $msg
*/
public static function log($msg){
Timer::add(1, function() use ($msg) {
Worker::log($msg);
}, null, false);
}
}

0 comments on commit 25b960f

Please sign in to comment.