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

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