]> granicus.if.org Git - icinga2/commitdiff
More bugfixes for timeperiods.
authorGunnar Beutner <gunnar.beutner@netways.de>
Tue, 16 Apr 2013 08:55:23 +0000 (10:55 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Tue, 16 Apr 2013 08:55:23 +0000 (10:55 +0200)
lib/base/dynamicobject.cpp
lib/icinga/icingaapplication.cpp
lib/icinga/legacytimeperiod.cpp

index 1418d1756f6b6a57697ca42e31775b2640a061e7..055d38ea876dcf6c49c4cb9c91a2feb3857713ee 100644 (file)
@@ -289,10 +289,12 @@ void DynamicObject::InternalSetAttribute(const String& name, const Value& data,
                if (!allowEditConfig && (it->second.GetType() & Attribute_Config))
                        BOOST_THROW_EXCEPTION(std::runtime_error("Config properties are immutable: '" + name + "'."));
 
-               it->second.SetValue(tx, data);
+               if (tx > it->second.GetTx()) {
+                       it->second.SetValue(tx, data);
 
-               if (it->second.GetType() & Attribute_Config)
-                       m_ConfigTx = tx;
+                       if (it->second.GetType() & Attribute_Config)
+                               m_ConfigTx = tx;
+               }
        }
 
        if (IsRegistered()) {
index 9e5f0966083bd753c33eda00ec9198bb9fec6ba9..5125e93abef1cb525a0342a4156d815f28496882 100644 (file)
@@ -185,7 +185,7 @@ shared_ptr<SSL_CTX> IcingaApplication::GetSSLContext(void) const
        return m_SSLContext;
 }
 
-bool IcingaApplication::ResolveMacro(const String& macro, const Dictionary::Ptr& cr, String *result) const
+bool IcingaApplication::ResolveMacro(const String& macro, const Dictionary::Ptr&, String *result) const
 {
        double now = Utility::GetTime();
 
index 51173626a20ae7a243bc67d77c5eee2a30498f45..8d9dae931fe138eb7c15c27c736b3b1604573115 100644 (file)
@@ -118,29 +118,31 @@ Array::Ptr LegacyTimePeriod::ScriptFunc(const TimePeriod::Ptr& tp, double begin,
 
        Dictionary::Ptr ranges = tp->Get("ranges");
 
-       time_t tempts = begin;
-       tm reference;
+
+
+       if (ranges) {
+               for (int i = 0; i <= (end - begin) / (24 * 60 * 60); i++) {
+                       time_t refts = begin + i * 24 * 60 * 60;
+                       tm reference;
 
 #ifdef _MSC_VER
-       tm *temp = localtime(&tempts);
+                       tm *temp = localtime(&refts);
 
-       if (temp == NULL) {
-               BOOST_THROW_EXCEPTION(posix_error()
-                   << boost::errinfo_api_function("localtime")
-                   << boost::errinfo_errno(errno));
-       }
+                       if (temp == NULL) {
+                               BOOST_THROW_EXCEPTION(posix_error()
+                                   << boost::errinfo_api_function("localtime")
+                                   << boost::errinfo_errno(errno));
+                       }
 
-       reference = *temp;
+                       reference = *temp;
 #else /* _MSC_VER */
-       if (localtime_r(&tempts, &reference) == NULL) {
-               BOOST_THROW_EXCEPTION(posix_error()
-                   << boost::errinfo_api_function("localtime_r")
-                   << boost::errinfo_errno(errno));
-       }
+                       if (localtime_r(&refts, &reference) == NULL) {
+                               BOOST_THROW_EXCEPTION(posix_error()
+                                   << boost::errinfo_api_function("localtime_r")
+                                   << boost::errinfo_errno(errno));
+                       }
 #endif /* _MSC_VER */
 
-       if (ranges) {
-               for (int i = 0; i <= (end - begin) / (24 * 60 * 60); i++) {
                        ObjectLock olock(ranges);
                        String key;
                        Value value;
@@ -150,8 +152,6 @@ Array::Ptr LegacyTimePeriod::ScriptFunc(const TimePeriod::Ptr& tp, double begin,
 
                                ProcessTimeRanges(value, &reference, segments);
                        }
-
-                       reference.tm_mday++;
                }
        }
 
@@ -159,4 +159,3 @@ Array::Ptr LegacyTimePeriod::ScriptFunc(const TimePeriod::Ptr& tp, double begin,
 
        return segments;
 }
-