]> granicus.if.org Git - icinga2/commitdiff
Fix Expression::Extract.
authorGunnar Beutner <gunnar@beutner.name>
Tue, 19 Mar 2013 13:13:58 +0000 (14:13 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Tue, 19 Mar 2013 13:13:58 +0000 (14:13 +0100)
lib/config/expression.cpp
lib/icinga/service-check.cpp

index 3a240a770685c73828b08578fc346ad258553954..93471cca25f5b34922c18e15c450a8fcb19b9640 100644 (file)
@@ -220,16 +220,17 @@ void Expression::Extract(const std::vector<String>& path, const ExpressionList::
        ASSERT(!path.empty());
 
        if (path[0] == m_Key) {
+               if (!m_Value.IsObjectType<ExpressionList>())
+                       BOOST_THROW_EXCEPTION(std::invalid_argument("Specified path does not exist."));
+
+               ExpressionList::Ptr exprl = m_Value;
+
                if (path.size() == 1) {
-                       result->AddExpression(*this);
+                       result->AddExpression(Expression("", OperatorExecute, exprl, m_DebugInfo));
 
                        return;
                }
 
-               if (!m_Value.IsObjectType<ExpressionList>())
-                       BOOST_THROW_EXCEPTION(std::invalid_argument("Specified path does not exist."));
-
-               ExpressionList::Ptr exprl = m_Value;
                std::vector<String> sub_path(path.begin() + 1, path.end());
                exprl->Extract(sub_path, result);
        } else if (m_Operator == OperatorExecute) {
index 76c02bb77f0103616435f2cb9ba02a57b7e2e805..64603cef8e53bff415dc400bcfe7f150046bed37 100644 (file)
@@ -643,6 +643,8 @@ void Service::BeginExecuteCheck(const boost::function<void (void)>& callback)
 {
        ASSERT(!OwnsLock());
 
+       bool reachable = IsReachable();
+
        {
                ObjectLock olock(this);
 
@@ -660,10 +662,9 @@ void Service::BeginExecuteCheck(const boost::function<void (void)>& callback)
 
                SetLastState(GetState());
                SetLastStateType(GetLastStateType());
+               SetLastReachable(reachable);
        }
 
-       SetLastReachable(IsReachable());
-
        /* keep track of scheduling info in case the check type doesn't provide its own information */
        Dictionary::Ptr checkInfo = boost::make_shared<Dictionary>();
        checkInfo->Set("schedule_start", GetNextCheck());