More bugfixes for timeperiods.

This commit is contained in:
Gunnar Beutner 2013-04-16 10:55:23 +02:00
parent 836c26da66
commit 2e600a7810
3 changed files with 27 additions and 26 deletions

View File

@ -289,11 +289,13 @@ void DynamicObject::InternalSetAttribute(const String& name, const Value& data,
if (!allowEditConfig && (it->second.GetType() & Attribute_Config)) if (!allowEditConfig && (it->second.GetType() & Attribute_Config))
BOOST_THROW_EXCEPTION(std::runtime_error("Config properties are immutable: '" + name + "'.")); BOOST_THROW_EXCEPTION(std::runtime_error("Config properties are immutable: '" + name + "'."));
if (tx > it->second.GetTx()) {
it->second.SetValue(tx, data); it->second.SetValue(tx, data);
if (it->second.GetType() & Attribute_Config) if (it->second.GetType() & Attribute_Config)
m_ConfigTx = tx; m_ConfigTx = tx;
} }
}
if (IsRegistered()) { if (IsRegistered()) {
/* We can't call GetSelf() in the constructor or destructor. /* We can't call GetSelf() in the constructor or destructor.

View File

@ -185,7 +185,7 @@ shared_ptr<SSL_CTX> IcingaApplication::GetSSLContext(void) const
return m_SSLContext; 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(); double now = Utility::GetTime();

View File

@ -118,11 +118,15 @@ Array::Ptr LegacyTimePeriod::ScriptFunc(const TimePeriod::Ptr& tp, double begin,
Dictionary::Ptr ranges = tp->Get("ranges"); Dictionary::Ptr ranges = tp->Get("ranges");
time_t tempts = begin;
if (ranges) {
for (int i = 0; i <= (end - begin) / (24 * 60 * 60); i++) {
time_t refts = begin + i * 24 * 60 * 60;
tm reference; tm reference;
#ifdef _MSC_VER #ifdef _MSC_VER
tm *temp = localtime(&tempts); tm *temp = localtime(&refts);
if (temp == NULL) { if (temp == NULL) {
BOOST_THROW_EXCEPTION(posix_error() BOOST_THROW_EXCEPTION(posix_error()
@ -132,15 +136,13 @@ Array::Ptr LegacyTimePeriod::ScriptFunc(const TimePeriod::Ptr& tp, double begin,
reference = *temp; reference = *temp;
#else /* _MSC_VER */ #else /* _MSC_VER */
if (localtime_r(&tempts, &reference) == NULL) { if (localtime_r(&refts, &reference) == NULL) {
BOOST_THROW_EXCEPTION(posix_error() BOOST_THROW_EXCEPTION(posix_error()
<< boost::errinfo_api_function("localtime_r") << boost::errinfo_api_function("localtime_r")
<< boost::errinfo_errno(errno)); << boost::errinfo_errno(errno));
} }
#endif /* _MSC_VER */ #endif /* _MSC_VER */
if (ranges) {
for (int i = 0; i <= (end - begin) / (24 * 60 * 60); i++) {
ObjectLock olock(ranges); ObjectLock olock(ranges);
String key; String key;
Value value; Value value;
@ -150,8 +152,6 @@ Array::Ptr LegacyTimePeriod::ScriptFunc(const TimePeriod::Ptr& tp, double begin,
ProcessTimeRanges(value, &reference, segments); ProcessTimeRanges(value, &reference, segments);
} }
reference.tm_mday++;
} }
} }
@ -159,4 +159,3 @@ Array::Ptr LegacyTimePeriod::ScriptFunc(const TimePeriod::Ptr& tp, double begin,
return segments; return segments;
} }