Skip to content

Commit ec99295

Browse files
authored
Merge pull request #10930 from Icinga/freeze-perfdata-arrays-2.16
[Backport support/2.16] Freeze perfdata arrays and remove locks in code using them
2 parents d2bf5d8 + 6dd5a73 commit ec99295

11 files changed

Lines changed: 15 additions & 9 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
@@ -197,7 +197,6 @@ void ElasticsearchWriter::AddCheckResult(const Dictionary::Ptr& fields, const Ch
197197
CheckCommand::Ptr checkCommand = checkable->GetCheckCommand();
198198

199199
if (perfdata) {
200-
ObjectLock olock(perfdata);
201200
for (const Value& val : perfdata) {
202201
PerfdataValue::Ptr pdv;
203202

lib/perfdata/gelfwriter.cpp

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

315315
if (perfdata) {
316-
ObjectLock olock(perfdata);
317316
for (const Value& val : perfdata) {
318317
PerfdataValue::Ptr pdv;
319318

lib/perfdata/graphitewriter.cpp

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

335335
CheckCommand::Ptr checkCommand = checkable->GetCheckCommand();
336336

337-
ObjectLock olock(perfdata);
338337
for (const Value& val : perfdata) {
339338
PerfdataValue::Ptr pdv;
340339

lib/perfdata/influxdbcommonwriter.cpp

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

268268
if (Array::Ptr perfdata = cr->GetPerformanceData()) {
269-
ObjectLock olock(perfdata);
270269
for (const Value& val : perfdata) {
271270
PerfdataValue::Ptr pdv;
272271

lib/perfdata/opentsdbwriter.cpp

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

318318
CheckCommand::Ptr checkCommand = checkable->GetCheckCommand();
319319

320-
ObjectLock olock(perfdata);
321320
for (const Value& val : perfdata) {
322321
PerfdataValue::Ptr pdv;
323322

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)