diff --git a/framework/Component/Config.php b/framework/Component/Config.php index 433a170..9fb0fbb 100644 --- a/framework/Component/Config.php +++ b/framework/Component/Config.php @@ -22,13 +22,11 @@ public function onInitialize(array $config = []) // Get \Swoole\Table object From \Server, So that we can share same dynamic config $this->cacheTable = app()->getServ()->configTable; - // If empty Config Table and this component get construct Lock - if ($this->cacheTable->count() == 0 && app()->getServ()->configTable_construct_lock->trylock()) { + if ($this->cacheTable->count() == 0 && app()->getWorker() == 0) { $configs = app()->pdo->createCommand("SELECT `name`,`value` FROM `site_config`")->queryAll(); foreach ($configs as $config) { $this->cacheTable->set($config["name"], [$this->valueField => $config["value"]]); } - app()->getServ()->configTable_construct_lock->unlock(); } } diff --git a/framework/Http/HttpServer.php b/framework/Http/HttpServer.php index da3671e..4bbca3d 100644 --- a/framework/Http/HttpServer.php +++ b/framework/Http/HttpServer.php @@ -160,9 +160,6 @@ protected function createSever() { $configTable->column('data', \Swoole\Table::TYPE_STRING, 256); $configTable->create(); $this->_server->configTable = $configTable; - - // 为 Dynamic Config construct行为创建一个锁,防止不同Worker下的Config同时写入(虽然这种情况也没什么事) - $this->_server->configTable_construct_lock = new \Swoole\Lock(SWOOLE_MUTEX); } // 欢迎信息