X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FForkController.php;h=2dde17be0803e073ea7a5e69c724d38cb4eac6dc;hb=4ca7f7a21c128b29c1a06093129d34150bfe6368;hp=655d7564a7dbdc385e4f15a06ee04a9e88682296;hpb=0d0059d36e7494792378c020f5de6033985c3637;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/ForkController.php b/includes/ForkController.php index 655d7564a7..2dde17be08 100644 --- a/includes/ForkController.php +++ b/includes/ForkController.php @@ -19,6 +19,7 @@ * * @file */ +use MediaWiki\MediaWikiServices; /** * Class for managing forking command line scripts. @@ -133,8 +134,7 @@ class ForkController { $this->termReceived = false; } } while ( count( $this->children ) ); - - $this->initProcess(); + pcntl_signal( SIGTERM, SIG_DFL ); return 'done'; } @@ -150,12 +150,14 @@ class ForkController { protected function prepareEnvironment() { global $wgMemc; - $wgMemc = null; // TODO: change all code that accesses this directly! - - // NOTE: we want to destroy global service instances before forking, - // so no external resources such as database connections get copied - // to the child processes. - \MediaWiki\MediaWikiServices::disableStorageBackend(); + // Don't share DB, storage, or memcached connections + MediaWikiServices::resetChildProcessServices(); + FileBackendGroup::destroySingleton(); + LockManagerGroup::destroySingletons(); + JobQueueGroup::destroySingletons(); + ObjectCache::clear(); + RedisConnectionPool::destroySingletons(); + $wgMemc = null; } /** @@ -177,7 +179,7 @@ class ForkController { } if ( !$pid ) { - $this->initProcess(); + $this->initChild(); $this->childNumber = $i; return 'child'; } else { @@ -189,10 +191,9 @@ class ForkController { return 'parent'; } - protected function initProcess() { - // Reset services, so we don't re-use connections. - \MediaWiki\MediaWikiServices::resetChildProcessServices(); - + protected function initChild() { + global $wgMemc, $wgMainCacheType; + $wgMemc = wfGetCache( $wgMainCacheType ); $this->children = null; pcntl_signal( SIGTERM, SIG_DFL ); }