Skip to content

Commit

Permalink
fix a bug of mysql
Browse files Browse the repository at this point in the history
  • Loading branch information
bingcool committed Nov 24, 2018
1 parent 51735a9 commit 7755368
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 11 deletions.
3 changes: 1 addition & 2 deletions score/Core/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,12 @@ public function catch() {
* @param boolean $prepend
* @return void
*/
public function afterRequest(callable $callback, $prepend = true) {
public function afterRequest(callable $callback, $prepend = false) {
if(is_callable($callback)) {
Hook::addHook(Hook::HOOK_AFTER_REQUEST, $callback, $prepend);
}else {
throw new \Exception(__NAMESPACE__.'::'.__function__.' the first param of type is callable');
}

}

/**
Expand Down
2 changes: 1 addition & 1 deletion score/Core/Cache/Redis.php → score/Core/Cache/Predis.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use Predis\Client;

class Redis {
class Predis {

/**
* $Predis redis实例
Expand Down
2 changes: 1 addition & 1 deletion score/Core/Crontab/AbstractCronController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ abstract class AbstractCronController extends ProcessController {
* runCron
* @param string $expression cron的表达式
* @param callable $func 闭包函数
* @return [type] [description]
* @return void
*/
public function runCron(string $expression, $func = null) {
$expression_key = md5($expression);
Expand Down
4 changes: 2 additions & 2 deletions score/Core/Db/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ public function setConfig(array $config = []) {
$this->config = array_merge($this->default_config, $this->config);
Db::setConfig($this->config);
}
// set hook call
Application::getApp()->afterRequest([$this,'clear']);
}

/**
Expand Down Expand Up @@ -246,8 +248,6 @@ public function selectMysql(array $extension = []) {
public function __call($method, $args) {
$this->setConfig();
$this->setCacheHandler();
// set hook call
Application::getApp()->afterRequest([$this,'clear']);
return Db::$method($args);
}

Expand Down
2 changes: 1 addition & 1 deletion score/Core/Memory/ChannelManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ChannelManager {
* @param string $name
* @param int $size
*/
public function addChannel(string $name, int $size = 1024 * 256) {
public function addChannel(string $name, int $size = 256 * 1024) {
if(!isset($this->list[$name])) {
$chan = new \Swoole\Channel($size);
$this->list[$name] = $chan;
Expand Down
7 changes: 3 additions & 4 deletions score/Core/Pools/PoolsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -403,16 +403,16 @@ public static function readByProcessName(string $name, float $timeOut = 0.1) {
* getProcessInWorker 获取一个worker进程内的所有的PoolsProcess进程
* @return array
*/
public function getProcessInWorker() {
public static function getProcessInWorker() {
return self::$processList;
}

/**
* killProcessInWorker 在一个worker内的PoolsProcess的进程退出,主要在workerstop中使用,由于PoolsProcess是产生于worker进程的,worker作为父进程,在退出是必须将子进程退出,否则成僵尸进程
* @return bool
*/
public function killProcessInWorker() {
$processList = $this->getProcessInWorker();
public static function killProcessInWorker() {
$processList = self::getProcessInWorker();
if($processList) {
foreach($processList as $process) {
$pid = $process->getPid();
Expand All @@ -421,6 +421,5 @@ public function killProcessInWorker() {
}
}
return true;

}
}

0 comments on commit 7755368

Please sign in to comment.