Module: check_mk
Branch: master
Commit: 7e067cf1b17c42a3e0b3c3e66d04d2f3956bfa49
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7e067cf1b17c42…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Fri Nov 25 16:10:27 2016 +0100
Fetched livestatus from downstream.
---
livestatus/src/Query.cc | 16 +++++++++++++---
livestatus/src/VariadicFilter.cc | 13 +------------
livestatus/src/VariadicFilter.h | 6 +++---
3 files changed, 17 insertions(+), 18 deletions(-)
diff --git a/livestatus/src/Query.cc b/livestatus/src/Query.cc
index 74577eb..5770ab8 100644
--- a/livestatus/src/Query.cc
+++ b/livestatus/src/Query.cc
@@ -270,7 +270,17 @@ void Query::parseAndOrLine(char *line, LogicalOperator andor,
return;
}
- filter.combineFilters(_logger, number, andor);
+ if (number > static_cast<int>(filter.size())) {
+ invalidHeader("error combining filters for table " + _table->name()
+
+ " with '" +
+ (andor == LogicalOperator::and_ ? "AND" : "OR")
+
+ "': expected " + to_string(number) +
+ " filters, but only " + to_string(filter.size()) + "
" +
+ (filter.size() == 1 ? "is" : "are") + " on
stack");
+ return;
+ }
+
+ filter.combineFilters(number, andor);
}
void Query::parseNegateLine(char *line, VariadicFilter &filter,
@@ -878,13 +888,13 @@ void Query::computeStatsGroupSpec(Query::_stats_group_spec_t
&groupspec,
void Query::doWait() {
// If no wait condition and no trigger is set,
// we do not wait at all.
- if (!_wait_condition.hasSubFilters() && _wait_trigger == nullptr) {
+ if (_wait_condition.size() == 0 && _wait_trigger == nullptr) {
return;
}
// If a condition is set, we check the condition. If it
// is already true, we do not need to way
- if (_wait_condition.hasSubFilters() &&
+ if (_wait_condition.size() > 0 &&
_wait_condition.accepts(_wait_object, _auth_user, _timezone_offset)) {
Debug(_logger) << "Wait condition true, no waiting neccessary";
return;
diff --git a/livestatus/src/VariadicFilter.cc b/livestatus/src/VariadicFilter.cc
index ddf6666..bd9bd44 100644
--- a/livestatus/src/VariadicFilter.cc
+++ b/livestatus/src/VariadicFilter.cc
@@ -23,10 +23,8 @@
// Boston, MA 02110-1301 USA.
#include "VariadicFilter.h"
-#include <ostream>
#include "AndingFilter.h"
#include "FilterVisitor.h"
-#include "Logger.h"
#include "OringFilter.h"
using std::make_unique;
@@ -70,16 +68,7 @@ void VariadicFilter::findIntLimits(const string &colum_nname, int
*lower,
}
}
-void VariadicFilter::combineFilters(Logger *logger, int count,
- LogicalOperator andor) {
- if (count > static_cast<int>(_subfilters.size())) {
- Informational(logger) << "Cannot combine " << count
<< " filters with '"
- << (andor == LogicalOperator::and_ ? "AND"
: "OR")
- << "': only " <<
_subfilters.size()
- << " are on stack";
- return;
- }
-
+void VariadicFilter::combineFilters(int count, LogicalOperator andor) {
auto variadic = VariadicFilter::make(andor);
for (auto i = 0; i < count; ++i) {
variadic->addSubfilter(_subfilters.back());
diff --git a/livestatus/src/VariadicFilter.h b/livestatus/src/VariadicFilter.h
index 1dcb7d2..efb6c72 100644
--- a/livestatus/src/VariadicFilter.h
+++ b/livestatus/src/VariadicFilter.h
@@ -26,12 +26,12 @@
#define VariadicFilter_h
#include "config.h" // IWYU pragma: keep
+#include <cstddef>
#include <deque>
#include <memory>
#include <string>
#include "Filter.h"
class FilterVisitor;
-class Logger;
enum class LogicalOperator { and_, or_ };
@@ -44,8 +44,8 @@ public:
void accept(FilterVisitor &v) override;
void addSubfilter(Filter *);
Filter *stealLastSubfiler();
- void combineFilters(Logger *logger, int count, LogicalOperator andor);
- bool hasSubFilters() { return !_subfilters.empty(); }
+ void combineFilters(int count, LogicalOperator andor);
+ size_t size() { return _subfilters.size(); }
_subfilters_t::iterator begin() { return _subfilters.begin(); }
_subfilters_t::iterator end() { return _subfilters.end(); }
void findIntLimits(const std::string &colum_nname, int *lower, int *upper,