Skip to content

Commit b35ecb6

Browse files
Merge pull request #10857 from Icinga/freeze-perfdata-arrays
Freeze perfdata arrays and remove locks in code using them
2 parents 4b7ec72 + 503e23e commit b35ecb6

12 files changed

Lines changed: 16 additions & 10 deletions

lib/icinga/checkresult.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,11 @@ double CheckResult::CalculateLatency() const
3333

3434
return latency;
3535
}
36+
37+
void CheckResult::SetPerformanceData(const Array::Ptr& value, bool suppress_events, const Value& cookie)
38+
{
39+
if (value) {
40+
value->Freeze();
41+
}
42+
ObjectImpl<CheckResult>::SetPerformanceData(value, suppress_events, cookie);
43+
}

lib/icinga/checkresult.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class CheckResult final : public ObjectImpl<CheckResult>
2222

2323
double CalculateExecutionTime() const;
2424
double CalculateLatency() const;
25+
void SetPerformanceData(const Array::Ptr& value, bool suppress_events = false, const Value& cookie = Empty) override;
2526
};
2627

2728
}

lib/icinga/checkresult.ti

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class CheckResult
6060
[state, enum] ServiceState "state";
6161
[state, enum] ServiceState previous_hard_state;
6262
[state] String output;
63-
[state] Array::Ptr performance_data;
63+
[state, set_virtual] Array::Ptr performance_data;
6464

6565
[state] bool active {
6666
default {{{ return true; }}}

lib/icinga/pluginutility.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,6 @@ String PluginUtility::FormatPerfdata(const Array::Ptr& perfdata, bool normalize)
185185

186186
std::ostringstream result;
187187

188-
ObjectLock olock(perfdata);
189-
190188
bool first = true;
191189
for (const Value& pdv : perfdata) {
192190
if (!first)

lib/perfdata/elasticsearchwriter.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ void ElasticsearchWriter::AddCheckResult(const Dictionary::Ptr& fields, const Ch
202202
CheckCommand::Ptr checkCommand = checkable->GetCheckCommand();
203203

204204
if (perfdata) {
205-
ObjectLock olock(perfdata);
206205
for (const Value& val : perfdata) {
207206
PerfdataValue::Ptr pdv;
208207

lib/perfdata/gelfwriter.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ void GelfWriter::CheckResultHandler(const Checkable::Ptr& checkable, const Check
198198
Array::Ptr perfdata = cr->GetPerformanceData();
199199

200200
if (perfdata) {
201-
ObjectLock olock(perfdata);
202201
for (const Value& val : perfdata) {
203202
PerfdataValue::Ptr pdv;
204203

lib/perfdata/graphitewriter.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ void GraphiteWriter::SendPerfdata(const Checkable::Ptr& checkable, const String&
226226

227227
CheckCommand::Ptr checkCommand = checkable->GetCheckCommand();
228228

229-
ObjectLock olock(perfdata);
230229
for (const Value& val : perfdata) {
231230
PerfdataValue::Ptr pdv;
232231

lib/perfdata/influxdbcommonwriter.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ void InfluxdbCommonWriter::CheckResultHandler(const Checkable::Ptr& checkable, c
213213
double ts = cr->GetExecutionEnd();
214214

215215
if (Array::Ptr perfdata = cr->GetPerformanceData()) {
216-
ObjectLock olock(perfdata);
217216
for (const Value& val : perfdata) {
218217
PerfdataValue::Ptr pdv;
219218

lib/perfdata/opentsdbwriter.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,6 @@ void OpenTsdbWriter::AddPerfdata(const Checkable::Ptr& checkable, const String&
310310

311311
CheckCommand::Ptr checkCommand = checkable->GetCheckCommand();
312312

313-
ObjectLock olock(perfdata);
314313
for (const Value& val : perfdata) {
315314
PerfdataValue::Ptr pdv;
316315

lib/perfdata/otlpmetricswriter.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ void OTLPMetricsWriter::CheckResultHandler(const Checkable::Ptr& checkable, cons
181181
auto endTime = cr->GetExecutionEnd();
182182

183183
Array::Ptr perfdata = cr->GetPerformanceData();
184-
ObjectLock olock(perfdata);
185184
for (const Value& val : perfdata) {
186185
PerfdataValue::Ptr pdv;
187186
if (val.IsObjectType<PerfdataValue>()) {

0 commit comments

Comments
 (0)