com web/rmtools: Use lock for PGO setup under concurrent builds: include/BuildVC.php script/snap.php
| From: | Anatol Belski | Date: | Wed, 04 Apr 2018 15:18:12 +0000 |
| Subject: | com web/rmtools: Use lock for PGO setup under concurrent builds: include/BuildVC.php script/snap.php | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-26899@lists.php.net to get a copy of this message | ||
Commit: 6a542320317874f8a3a6a7ab6b8059f8546de245
Author: Anatol Belski <ab@php.net> Wed, 4 Apr 2018 17:18:12 +0200
Parents: c0e176ad6c292ba50a371986c95a478fabc42658
Branches: master
Link: http://git.php.net/?p=web/rmtools.git;a=commitdiff;h=6a542320317874f8a3a6a7ab6b8059f8546de245
Log:
Use lock for PGO setup under concurrent builds
Changed paths:
M include/BuildVC.php
M script/snap.php
Diff:
diff --git a/include/BuildVC.php b/include/BuildVC.php
index f81e1bd..1bf89af 100644
--- a/include/BuildVC.php
+++ b/include/BuildVC.php
@@ -27,6 +27,8 @@ class BuildVC {
public $zip_debug_filename;
public $zip_test_filename;
+ protected $pgo_init_lock_fd;
+
function __construct(Branch $branch, $build_name)
{
/* XXX this has to be merged with PeclBuildVC and any other, be it per trait or inheritance. */
@@ -77,6 +79,8 @@ class BuildVC {
}
$this->env = $env;
+
+ $this->pgo_init_lock_fd = NULL;
}
function setSourceDir($src_dir)
@@ -120,6 +124,23 @@ class BuildVC {
$this->log_buildconf = $ret['log'];
}
+ function pgoInitLock()
+ {
+ if (is_null($this->pgo_init_lock_fd)) {
+ $this->pgo_init_lock_fd = fopen(TMP_DIR . DIRECTORY_SEPARATOR .
"sdk_pgo_init.lock");
+ flock($this->pgo_init_lock_fd, LOCK_EX);
+ }
+ }
+
+ function pgoInitUnlock()
+ {
+ if (!is_null($this->pgo_init_lock_fd)) {
+ flock($this->pgo_init_lock_fd, LOCK_UN);
+ @unlink(TMP_DIR . DIRECTORY_SEPARATOR . "sdk_pgo_init.lock");
+ $this->pgo_init_lock_fd = NULL;
+ }
+ }
+
function isPgoSetup()
{
$env = $this->env;
@@ -128,6 +149,7 @@ class BuildVC {
$cmd = 'phpsdk_pgo --ready';
$ret = exec_single_log($cmd, $this->build_dir, $env);
if (!$ret) {
+ $this->pgoInitUnlock();
throw new \Exception('phpsdk_pgo --ready failed' . (isset($ret["log"]) ?
": \n$ret[log]" : ""));
}
@@ -143,6 +165,7 @@ class BuildVC {
$cmd = 'phpsdk_pgo --init';
$ret = exec_single_log($cmd, $this->build_dir, $env);
if (!$ret || 0 !== (int)$ret["return_value"]) {
+ $this->pgoInitUnlock();
throw new \Exception('phpsdk_pgo --init failed' . (isset($ret["log"]) ?
": \n$ret[log]" : ""));
}
$this->log_pgo .= $ret["log"];
diff --git a/script/snap.php b/script/snap.php
index 27171e8..13173d0 100644
--- a/script/snap.php
+++ b/script/snap.php
@@ -125,12 +125,14 @@ if ($branch->hasNewRevision() ||
!$branch->isLastRevisionExported($branch->getLa
only needs to be done once for setup. In further
also, if there are any difference with TS/NTS,
there might be some separate setup needed. */
+ $build->pgoInitLock();
if (!$build->isPgoSetup()) {
echo "Preparing PGO training environment\n";
$build->configure();
$build->make();
$build->pgoInit();
}
+ $build->pgoInitUnlock();
echo "Creating PGI build\n";
$build->configure(' "--enable-pgi" ');
}