summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2023-12-21 15:14:37 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-12-24 10:39:07 +0000
commit52f41ff24303e3cc6f842d1eb62f41ba6d0c77b7 (patch)
treebcbcc61ba873de64351fb161bf9c4b051a8615a9 /meta/lib
parentcd125f1703fcf06c995cc6c74990a6a70fdc9536 (diff)
downloadpoky-52f41ff24303e3cc6f842d1eb62f41ba6d0c77b7.tar.gz
lib/prservice: Improve lock handling robustness
It is possible we could crash holding a lock whilst parsing in this code. Switch to use utils.fileslocked() in the with expression to avoid this. This may be causing some of our strange intermittent failures in PRServ tests. (From OE-Core rev: 4e59db15e5df2cc3d0ae042454812a2d54cef77b) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oe/prservice.py4
1 files changed, 1 insertions, 3 deletions
diff --git a/meta/lib/oe/prservice.py b/meta/lib/oe/prservice.py
index 2f2a0c128a..c41242c878 100644
--- a/meta/lib/oe/prservice.py
+++ b/meta/lib/oe/prservice.py
@@ -78,8 +78,7 @@ def prserv_export_tofile(d, metainfo, datainfo, lockdown, nomax=False):
78 bb.utils.mkdirhier(d.getVar('PRSERV_DUMPDIR')) 78 bb.utils.mkdirhier(d.getVar('PRSERV_DUMPDIR'))
79 df = d.getVar('PRSERV_DUMPFILE') 79 df = d.getVar('PRSERV_DUMPFILE')
80 #write data 80 #write data
81 lf = bb.utils.lockfile("%s.lock" % df) 81 with open(df, "a") as f, bb.utils.fileslocked(["%s.lock" % df]) as locks:
82 with open(df, "a") as f:
83 if metainfo: 82 if metainfo:
84 #dump column info 83 #dump column info
85 f.write("#PR_core_ver = \"%s\"\n\n" % metainfo['core_ver']); 84 f.write("#PR_core_ver = \"%s\"\n\n" % metainfo['core_ver']);
@@ -113,7 +112,6 @@ def prserv_export_tofile(d, metainfo, datainfo, lockdown, nomax=False):
113 if not nomax: 112 if not nomax:
114 for i in idx: 113 for i in idx:
115 f.write("PRAUTO_%s_%s = \"%s\"\n" % (str(datainfo[idx[i]]['version']),str(datainfo[idx[i]]['pkgarch']),str(datainfo[idx[i]]['value']))) 114 f.write("PRAUTO_%s_%s = \"%s\"\n" % (str(datainfo[idx[i]]['version']),str(datainfo[idx[i]]['pkgarch']),str(datainfo[idx[i]]['value'])))
116 bb.utils.unlockfile(lf)
117 115
118def prserv_check_avail(d): 116def prserv_check_avail(d):
119 host_params = list([_f for _f in (d.getVar("PRSERV_HOST") or '').split(':') if _f]) 117 host_params = list([_f for _f in (d.getVar("PRSERV_HOST") or '').split(':') if _f])