summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorFrédéric Boisnard <fredericx.boisnard@intel.com>2013-10-16 18:13:07 +0200
committerDavid Wagner <david.wagner@intel.com>2014-02-12 17:04:11 +0100
commit010b86413755ea59f099e230eb6590b875e787e3 (patch)
treea8a864e82e5603163ad055b5734c560fc7d5ede5 /tools
parentaa0821726682aab62a501a67ddfc342c3f23053e (diff)
downloadexternal_parameter-framework-010b86413755ea59f099e230eb6590b875e787e3.zip
external_parameter-framework-010b86413755ea59f099e230eb6590b875e787e3.tar.gz
external_parameter-framework-010b86413755ea59f099e230eb6590b875e787e3.tar.bz2
Allow concurent generation of XML routing files
BZ: 145938 XML generation is impossible when multiple instances of the script hostDomainGeneration are run (this is typically the case with the current Android Make process). This is because the way the ports used to communicate with test-platform and parameter-framework are chosen is not protected agains concurrent executions. This patch protects the initialization of the test-platform and parameter-framework agains concurrent executions using a flock. In particular, it ensures that the ports chosen are reserved to a specific process. Change-Id: I3d8fee2b20313814c79f5390851ad57dc696cc28 Signed-off-by: Frédéric Boisnard <fredericx.boisnard@intel.com>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/xmlGenerator/hostDomainGenerator.sh19
1 files changed, 19 insertions, 0 deletions
diff --git a/tools/xmlGenerator/hostDomainGenerator.sh b/tools/xmlGenerator/hostDomainGenerator.sh
index 1d4d79b..c618f46 100755
--- a/tools/xmlGenerator/hostDomainGenerator.sh
+++ b/tools/xmlGenerator/hostDomainGenerator.sh
@@ -65,6 +65,7 @@ TargetRoot="$ANDROID_PRODUCT_OUT/system"
# Global variables
TPSocket=5003
PFWSocket=5000
+PFWStartTimeout=60
tmpFile=$(mktemp)
testPlatformPID=0
@@ -82,6 +83,7 @@ export LD_LIBRARY_PATH="$HostRoot/lib:${LD_LIBRARY_PATH:-}"
# Setup clean trap, it will be called automatically on exit
clean_up () {
status=$?
+
echo "Clean sub process: $testPlatformPID"
test $testPlatformPID != 0 && kill $testPlatformPID 2>&1
rm "$tmpFile"
@@ -140,7 +142,9 @@ initTestPlatform () {
formatConfigFile "$1" >"$tmpFile"
# Check port is free
+ echo "Checking port $TPSocket for TestPlatform"
! portIsInUse $TPSocket || return 4
+ echo "Port $TPSocket is available for TestPlatform"
# Start test platform
$testPlatform "$tmpFile" $TPSocket 2>&5 &
@@ -172,7 +176,9 @@ launchTestPlatform () {
$TPSendCommand setFailureOnFailedSettingsLoad false
# Check port is free
+ echo "Checking port $PFWSocket for PFW"
! portIsInUse $PFWSocket || return 5
+ echo "Port $PFWSocket is available for PFW"
$TPSendCommand start
if ! retry "$remoteProcess $PFWHost $PFWSocket help" 2 0.1
@@ -215,8 +221,21 @@ deleteEscapedNewLines () {
linkLibrary libremote-processor_host.so libremote-processor.so
# Start test platform and the PFW
+#
+# Creation of a critical section to ensure that the startup of the PFW (involving
+# sockets creation to communicate with the test platform and the PFW) is serialized
+# between potential concurrent execution of this script
+#
+# Acquire an exclusive lock on the file descriptor 200
+exec 200>/var/lock/.hostDomainGenerator.lockfile
+flock --timeout $PFWStartTimeout 200
+
+# Start the pfw using different socket if it fails
safeStartPFW
+# Release the lock
+flock --unlock 200
+
PFWSendCommand="$remoteProcess $PFWHost $PFWSocket"
$PFWSendCommand setTuningMode on