diff options
author | Tobias Henkel <tobias.henkel@bmw-carit.de> | 2013-11-12 09:34:03 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-11-12 16:00:20 +0000 |
commit | 8a30be803e91e66688cfc27ca4c21f26fb22eed8 (patch) | |
tree | 1c75da7bced42ff98b026d99e2408830bfa0e247 | |
parent | d2735ac44887c7e01134d6870a4875a786501eba (diff) | |
download | openembedded-core-8a30be803e91e66688cfc27ca4c21f26fb22eed8.tar.gz openembedded-core-8a30be803e91e66688cfc27ca4c21f26fb22eed8.tar.bz2 openembedded-core-8a30be803e91e66688cfc27ca4c21f26fb22eed8.zip |
icecc: Fix race condition when packaging toolchain
In the current implementation there can be a race condition while
creating the toolchain archive causing the build to break.
This is fixed by locking the toolchain archiving step using flock.
Signed-off-by: Tobias Henkel <tobias.henkel@bmw-carit.de>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/classes/icecc.bbclass | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/meta/classes/icecc.bbclass b/meta/classes/icecc.bbclass index 3255839942..1f53f855fe 100644 --- a/meta/classes/icecc.bbclass +++ b/meta/classes/icecc.bbclass @@ -202,6 +202,21 @@ def icc_get_and_check_tool(bb, d, tool): else: return t +wait_for_file() { + local TIME_ELAPSED=0 + local FILE_TO_TEST=$1 + local TIMEOUT=$2 + until [ -f "$FILE_TO_TEST" ] + do + TIME_ELAPSED=`expr $TIME_ELAPSED + 1` + if [ $TIME_ELAPSED -gt $TIMEOUT ] + then + return 1 + fi + sleep 1 + done +} + def set_icecc_env(): # dummy python version of set_icecc_env return @@ -247,10 +262,22 @@ set_icecc_env() { ICECC_AS="`which as`" fi - if [ ! -r "${ICECC_VERSION}" ] + if [ ! -f "${ICECC_VERSION}.done" ] then mkdir -p "`dirname "${ICECC_VERSION}"`" - ${ICECC_ENV_EXEC} "${ICECC_CC}" "${ICECC_CXX}" "${ICECC_AS}" "${ICECC_VERSION}" + + # the ICECC_VERSION generation step must be locked by a mutex + # in order to prevent race conditions + if flock -n "${ICECC_VERSION}.lock" \ + ${ICECC_ENV_EXEC} "${ICECC_CC}" "${ICECC_CXX}" "${ICECC_AS}" "${ICECC_VERSION}" + then + touch "${ICECC_VERSION}.done" + elif [ ! wait_for_file "${ICECC_VERSION}.done" 30 ] + then + # locking failed so wait for ${ICECC_VERSION}.done to appear + bbwarn "Timeout waiting for ${ICECC_VERSION}.done" + return + fi fi export ICECC_VERSION ICECC_CC ICECC_CXX |