diff options
author | Mariano Lopez <mariano.lopez@linux.intel.com> | 2015-06-26 05:56:00 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-07-08 00:01:18 +0100 |
commit | cd379328b9ee211d87d65490af6d6f79b77ed80a (patch) | |
tree | e86dba3ccd29a44df958267beff88d6e464297e5 /meta/classes | |
parent | 046f1ab727e275f146284a051ac966f210d2478e (diff) | |
download | poky-cd379328b9ee211d87d65490af6d6f79b77ed80a.tar.gz |
report-error.bbclass: Added file syncronization.
errorreport_handler would fail if several errors are
triggered at the same time because of two proccess
writting to the same file. This patch add the required
syncronization to handle concurrent process.
[YP #7899]
(From OE-Core rev: 8b20eaf7cbadd0cd87cfa192d60ca1b7da435216)
Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r-- | meta/classes/report-error.bbclass | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/meta/classes/report-error.bbclass b/meta/classes/report-error.bbclass index c5aaaa8a11..11eee9bdc5 100644 --- a/meta/classes/report-error.bbclass +++ b/meta/classes/report-error.bbclass | |||
@@ -18,7 +18,6 @@ def errorreport_getdata(e): | |||
18 | def errorreport_savedata(e, newdata, file): | 18 | def errorreport_savedata(e, newdata, file): |
19 | import json | 19 | import json |
20 | logpath = e.data.getVar('ERR_REPORT_DIR', True) | 20 | logpath = e.data.getVar('ERR_REPORT_DIR', True) |
21 | bb.utils.mkdirhier(logpath) | ||
22 | datafile = os.path.join(logpath, file) | 21 | datafile = os.path.join(logpath, file) |
23 | with open(datafile, "w") as f: | 22 | with open(datafile, "w") as f: |
24 | json.dump(newdata, f, indent=4, sort_keys=True) | 23 | json.dump(newdata, f, indent=4, sort_keys=True) |
@@ -27,7 +26,11 @@ def errorreport_savedata(e, newdata, file): | |||
27 | python errorreport_handler () { | 26 | python errorreport_handler () { |
28 | import json | 27 | import json |
29 | 28 | ||
29 | logpath = e.data.getVar('ERR_REPORT_DIR', True) | ||
30 | datafile = os.path.join(logpath, "error-report.txt") | ||
31 | |||
30 | if isinstance(e, bb.event.BuildStarted): | 32 | if isinstance(e, bb.event.BuildStarted): |
33 | bb.utils.mkdirhier(logpath) | ||
31 | data = {} | 34 | data = {} |
32 | machine = e.data.getVar("MACHINE", False) | 35 | machine = e.data.getVar("MACHINE", False) |
33 | data['machine'] = machine | 36 | data['machine'] = machine |
@@ -38,7 +41,9 @@ python errorreport_handler () { | |||
38 | data['failures'] = [] | 41 | data['failures'] = [] |
39 | data['component'] = e.getPkgs()[0] | 42 | data['component'] = e.getPkgs()[0] |
40 | data['branch_commit'] = base_detect_branch(e.data) + ": " + base_detect_revision(e.data) | 43 | data['branch_commit'] = base_detect_branch(e.data) + ": " + base_detect_revision(e.data) |
44 | lock = bb.utils.lockfile(datafile + '.lock') | ||
41 | errorreport_savedata(e, data, "error-report.txt") | 45 | errorreport_savedata(e, data, "error-report.txt") |
46 | bb.utils.unlockfile(lock) | ||
42 | 47 | ||
43 | elif isinstance(e, bb.build.TaskFailed): | 48 | elif isinstance(e, bb.build.TaskFailed): |
44 | task = e.task | 49 | task = e.task |
@@ -56,12 +61,16 @@ python errorreport_handler () { | |||
56 | 61 | ||
57 | else: | 62 | else: |
58 | taskdata['log'] = "No Log" | 63 | taskdata['log'] = "No Log" |
64 | lock = bb.utils.lockfile(datafile + '.lock') | ||
59 | jsondata = json.loads(errorreport_getdata(e)) | 65 | jsondata = json.loads(errorreport_getdata(e)) |
60 | jsondata['failures'].append(taskdata) | 66 | jsondata['failures'].append(taskdata) |
61 | errorreport_savedata(e, jsondata, "error-report.txt") | 67 | errorreport_savedata(e, jsondata, "error-report.txt") |
68 | bb.utils.unlockfile(lock) | ||
62 | 69 | ||
63 | elif isinstance(e, bb.event.BuildCompleted): | 70 | elif isinstance(e, bb.event.BuildCompleted): |
71 | lock = bb.utils.lockfile(datafile + '.lock') | ||
64 | jsondata = json.loads(errorreport_getdata(e)) | 72 | jsondata = json.loads(errorreport_getdata(e)) |
73 | bb.utils.unlockfile(lock) | ||
65 | failures = jsondata['failures'] | 74 | failures = jsondata['failures'] |
66 | if(len(failures) > 0): | 75 | if(len(failures) > 0): |
67 | filename = "error_report_" + e.data.getVar("BUILDNAME", False)+".txt" | 76 | filename = "error_report_" + e.data.getVar("BUILDNAME", False)+".txt" |