summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2019-08-03 11:49:23 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-08-03 23:56:01 +0100
commit6c7c0cefd34067311144a1d4c01986fe0a4aef26 (patch)
tree3f711509e625e7aae4d4cc2f2044b32dd6b479ac
parentdad9cd5cca1a09f33f0fd82a6bcbed31936ad6c8 (diff)
downloadopenembedded-core-contrib-6c7c0cefd34067311144a1d4c01986fe0a4aef26.tar.gz
sstate: Reduce race windows
When we write to the sstate directory we try to do so atomically so consumers either see one version or another but never an imcomplete file. Unfortunately this is reliant on filesystem support and with some NFS configurations a replaced file would be lost from memory even if users held open descriptors. It makes sense to try and avoid replacing existing files where we can. (From OE-Core rev: 18cdc087fd5da30e2b31f3d4e81b153cd36ca844) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/sstate.bbclass12
1 files changed, 11 insertions, 1 deletions
diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass
index ee029196da..a0ca199867 100644
--- a/meta/classes/sstate.bbclass
+++ b/meta/classes/sstate.bbclass
@@ -755,6 +755,11 @@ sstate_task_postfunc[dirs] = "${WORKDIR}"
sstate_create_package () {
TFILE=`mktemp ${SSTATE_PKG}.XXXXXXXX`
+ # Exit earlu if it already exists
+ if [ -e ${SSTATE_PKG} ]; then
+ return
+ fi
+
# Use pigz if available
OPT="-czS"
if [ -x "$(command -v pigz)" ]; then
@@ -774,7 +779,12 @@ sstate_create_package () {
tar $OPT --file=$TFILE --files-from=/dev/null
fi
chmod 0664 $TFILE
- mv -f $TFILE ${SSTATE_PKG}
+ # Skip if it was already created by some other process
+ if [ ! -e ${SSTATE_PKG} ]; then
+ mv -f $TFILE ${SSTATE_PKG}
+ else
+ rm $TFILE
+ fi
}
python sstate_sign_package () {