diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-12-21 15:14:37 +0000 |
---|---|---|
committer | Steve Sakoman <steve@sakoman.com> | 2024-01-31 04:10:24 -1000 |
commit | f890240f06056ee25f3d364fa23f1456b8c1c8c2 (patch) | |
tree | 5414aba413f8aa5e07027898b1e2521976a4958b /meta | |
parent | 8de5dd79c0d1ebbe3581c564849ef34c4b7470e0 (diff) | |
download | poky-f890240f06056ee25f3d364fa23f1456b8c1c8c2.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: 4e3c9526c2389fd08d86d986014313e1d404f1fb)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 4e59db15e5df2cc3d0ae042454812a2d54cef77b)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/lib/oe/prservice.py | 4 |
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 | ||
118 | def prserv_check_avail(d): | 116 | def 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]) |