Blame SOURCES/0001-wait-child-with-os-wait.patch

67f0f6
commit e7b3e6817421763eee37cb35ef8627bdd37a3690
67f0f6
Author: Chunyu Hu <chuhu@redhat.com>
67f0f6
Date:   Wed May 6 18:59:43 2020 +0800
67f0f6
67f0f6
    Wait child with os.wait()
67f0f6
    
67f0f6
    os.popen() is an async method, it fork() child and exec() in child
67f0f6
    with the arg command. If it's slow enough, main process could get
67f0f6
    incomplete result.
67f0f6
    
67f0f6
    During our test, we find python3 is faster than python2,after coverting
67f0f6
    to python3, 'groupadd' usually doesn't finish when the followed step iter
67f0f6
    on groups, we would get '-1' as the groupid and lead to error.
67f0f6
    
67f0f6
    To reproduce it with python3:
67f0f6
    /root/rpmbuild/BUILD/libhugetlbfs-2.21/huge_page_setup_helper.py <
67f0f6
    128
67f0f6
    hugepages
67f0f6
    hugepages root
67f0f6
    EOF
67f0f6
    
67f0f6
    ...
67f0f6
    hugeadm:ERROR: Invalid group specification (-1)
67f0f6
    ...
67f0f6
    
67f0f6
    Signed-off-by: Chunyu Hu <chuhu@redhat.com>
67f0f6
67f0f6
diff --git a/huge_page_setup_helper.py b/huge_page_setup_helper.py
67f0f6
index a9ba2bf..01fc8dc 100755
67f0f6
--- a/huge_page_setup_helper.py
67f0f6
+++ b/huge_page_setup_helper.py
67f0f6
@@ -169,6 +169,10 @@ else:
67f0f6
         os.popen("/usr/sbin/groupadd %s" % userGroupReq)
67f0f6
     else:
67f0f6
         print("/usr/sbin/groupadd %s" % userGroupReq)
67f0f6
+
67f0f6
+    # wait for the groupadd finish
67f0f6
+    os.wait()
67f0f6
+
67f0f6
     groupNames = os.popen("/usr/bin/getent group %s" % userGroupReq).readlines()
67f0f6
     for line in groupNames:
67f0f6
         curGroupName = line.split(":")[0]
67f0f6
@@ -244,6 +248,9 @@ else:
67f0f6
     print("/usr/bin/hugeadm --set-recommended-shmmax")
67f0f6
     print()
67f0f6
 
67f0f6
+# wait for the hugepage setups finish
67f0f6
+os.wait()
67f0f6
+
67f0f6
 # figure out what that shmmax value we just set was
67f0f6
 hugeadmexplain = os.popen("/usr/bin/hugeadm --explain 2>/dev/null").readlines()
67f0f6
 for line in hugeadmexplain: