[oe-commits] [openembedded-core] 32/32: sstate: Reduce race windows

git at git.openembedded.org git at git.openembedded.org
Sat Aug 3 10:52:39 UTC 2019


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit ccec39d3158a7785e5ec94352c6d2d5ab2521ced
Author: Richard Purdie <richard.purdie at linuxfoundation.org>
AuthorDate: Sat Aug 3 11:49:23 2019 +0100

    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.
    
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 meta/classes/sstate.bbclass | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass
index aa58414..1122222 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 () {

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list