|
|
@@ -33,7 +33,7 @@ class Worker
|
|
|
*
|
|
|
* @var string
|
|
|
*/
|
|
|
- const VERSION = '3.4.7';
|
|
|
+ const VERSION = '3.4.8';
|
|
|
|
|
|
/**
|
|
|
* Status starting.
|
|
|
@@ -215,7 +215,7 @@ class Worker
|
|
|
*
|
|
|
* @var Protocols\ProtocolInterface
|
|
|
*/
|
|
|
- public $protocol = '';
|
|
|
+ public $protocol = 'tcp';
|
|
|
|
|
|
/**
|
|
|
* Root path for autoload.
|
|
|
@@ -988,6 +988,8 @@ class Worker
|
|
|
*
|
|
|
* @param int $worker_id
|
|
|
* @param int $pid
|
|
|
+ *
|
|
|
+ * @return integer
|
|
|
*/
|
|
|
protected static function getId($worker_id, $pid)
|
|
|
{
|
|
|
@@ -1195,6 +1197,7 @@ class Worker
|
|
|
Timer::add(self::KILL_WORKER_TIMER_TIME, 'posix_kill', array($one_worker_pid, SIGKILL), false);
|
|
|
} // For child processes.
|
|
|
else {
|
|
|
+ reset(self::$_workers);
|
|
|
$worker = current(self::$_workers);
|
|
|
// Try to emit onWorkerReload callback.
|
|
|
if ($worker->onWorkerReload) {
|
|
|
@@ -1325,7 +1328,8 @@ class Worker
|
|
|
{
|
|
|
// For master process.
|
|
|
if (self::$_masterPid === posix_getpid()) {
|
|
|
- file_put_contents(self::$_statisticsFile, "Trans ipv4 ipv6 Recv-Q Send-Q Bytes-R Bytes-W Local Address Foreign Address PID ID Protocol Worker\n", FILE_APPEND);
|
|
|
+ file_put_contents(self::$_statisticsFile, "------------------------------------------------------------ WORKERMAN CONNECTION STATUS --------------------------------------------------------------------------------\n", FILE_APPEND);
|
|
|
+ file_put_contents(self::$_statisticsFile, "Trans ipv4 ipv6 Recv-Q Send-Q Bytes-R Bytes-W Local Address Foreign Address Status PID ID Protocol Worker\n", FILE_APPEND);
|
|
|
chmod(self::$_statisticsFile, 0722);
|
|
|
foreach (self::getAllWorkerPids() as $worker_pid) {
|
|
|
posix_kill($worker_pid, SIGIO);
|
|
|
@@ -1353,9 +1357,12 @@ class Worker
|
|
|
|
|
|
$pid = posix_getpid();
|
|
|
$str = '';
|
|
|
+ reset(self::$_workers);
|
|
|
+ $current_worker = current(self::$_workers);
|
|
|
+ $default_worker_name = $current_worker->name;
|
|
|
+
|
|
|
/** @var Worker $worker */
|
|
|
- foreach(self::$_workers as $worker) {
|
|
|
- foreach($worker->connections as $connection) {
|
|
|
+ foreach(TcpConnection::$connections as $connection) {
|
|
|
/** @var Connection\TcpConnection $connection */
|
|
|
$transport = $connection->transport;
|
|
|
$ipv4 = $connection->isIpV4() ? ' 1' : ' 0';
|
|
|
@@ -1364,6 +1371,7 @@ class Worker
|
|
|
$send_q = $bytes_format($connection->getSendBufferQueueSize());
|
|
|
$local_address = $connection->getLocalAddress();
|
|
|
$remote_address = $connection->getRemoteAddress();
|
|
|
+ $state = $connection->getStatus(false);
|
|
|
$bytes_read = $bytes_format($connection->bytesRead);
|
|
|
$bytes_written = $bytes_format($connection->bytesWritten);
|
|
|
$id = $connection->id;
|
|
|
@@ -1373,18 +1381,16 @@ class Worker
|
|
|
} else {
|
|
|
$protocol = $connection->protocol;
|
|
|
}
|
|
|
-
|
|
|
+ $worker_name = isset($connection->worker) ? $connection->worker->name : $default_worker_name;
|
|
|
$str .= str_pad($transport, 8).str_pad($ipv4, 7).str_pad($ipv6, 7)
|
|
|
.str_pad($recv_q, 13).str_pad($send_q, 13).str_pad($bytes_read, 13).str_pad($bytes_written, 13)
|
|
|
- .str_pad($local_address, 22).' '.str_pad($remote_address, 22).' '.str_pad($pid, 8).str_pad($id, 10)
|
|
|
- .str_pad($protocol, 12).' '.$worker->name."\n" ;
|
|
|
- }
|
|
|
+ .str_pad($local_address, 22).' '.str_pad($remote_address, 22).' ' . str_pad($state, 12) . str_pad($pid, 8).str_pad($id, 10)
|
|
|
+ .str_pad($protocol, 12).' '.$worker_name."\n" ;
|
|
|
+
|
|
|
}
|
|
|
if ($str) {
|
|
|
file_put_contents(self::$_statisticsFile, $str, FILE_APPEND);
|
|
|
}
|
|
|
-
|
|
|
- reset(self::$_workers);
|
|
|
}
|
|
|
|
|
|
/**
|