mirror of
https://git.yoctoproject.org/poky
synced 2026-01-29 21:08:42 +01:00
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: 4e3c9526c2389fd08d86d986014313e1d404f1fb) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 4e59db15e5df2cc3d0ae042454812a2d54cef77b) Signed-off-by: Steve Sakoman <steve@sakoman.com>
This commit is contained in:
committed by
Steve Sakoman
parent
8de5dd79c0
commit
f890240f06
@@ -78,8 +78,7 @@ def prserv_export_tofile(d, metainfo, datainfo, lockdown, nomax=False):
|
||||
bb.utils.mkdirhier(d.getVar('PRSERV_DUMPDIR'))
|
||||
df = d.getVar('PRSERV_DUMPFILE')
|
||||
#write data
|
||||
lf = bb.utils.lockfile("%s.lock" % df)
|
||||
with open(df, "a") as f:
|
||||
with open(df, "a") as f, bb.utils.fileslocked(["%s.lock" % df]) as locks:
|
||||
if metainfo:
|
||||
#dump column info
|
||||
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):
|
||||
if not nomax:
|
||||
for i in idx:
|
||||
f.write("PRAUTO_%s_%s = \"%s\"\n" % (str(datainfo[idx[i]]['version']),str(datainfo[idx[i]]['pkgarch']),str(datainfo[idx[i]]['value'])))
|
||||
bb.utils.unlockfile(lf)
|
||||
|
||||
def prserv_check_avail(d):
|
||||
host_params = list([_f for _f in (d.getVar("PRSERV_HOST") or '').split(':') if _f])
|
||||
|
||||
Reference in New Issue
Block a user