Improve timing behavior for UpdateObjectAuthority calls

refs #11765
This commit is contained in:
Gunnar Beutner 2016-05-11 13:04:39 +02:00
parent 208d035db4
commit 17fa327159
5 changed files with 11 additions and 11 deletions

View File

@ -303,8 +303,7 @@ int DaemonCommand::Run(const po::variables_map& vm, const std::vector<std::strin
sigaction(SIGHUP, &sa, NULL); sigaction(SIGHUP, &sa, NULL);
#endif /* _WIN32 */ #endif /* _WIN32 */
/* update object authority */ ApiListener::UpdateObjectAuthority();
ApiListener::UpdateObjectAuthorityAsync();
return Application::GetInstance()->Run(); return Application::GetInstance()->Run();
} }

View File

@ -431,6 +431,9 @@ void ApiListener::SyncClient(const JsonRpcConnection::Ptr& aclient, const Endpoi
ReplayLog(aclient); ReplayLog(aclient);
if (endpoint->GetZone() == Zone::GetLocalZone())
UpdateObjectAuthority();
Log(LogInformation, "ApiListener") Log(LogInformation, "ApiListener")
<< "Finished sending replay log for endpoint '" << endpoint->GetName() << "'."; << "Finished sending replay log for endpoint '" << endpoint->GetName() << "'.";
} catch (const std::exception& ex) { } catch (const std::exception& ex) {

View File

@ -98,7 +98,7 @@ public:
static Value HelloAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params); static Value HelloAPIHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params);
static void UpdateObjectAuthorityAsync(void); static void UpdateObjectAuthority(void);
protected: protected:
virtual void OnConfigLoaded(void) override; virtual void OnConfigLoaded(void) override;

View File

@ -34,7 +34,7 @@ static bool ObjectNameLessComparer(const ConfigObject::Ptr& a, const ConfigObjec
return a->GetName() < b->GetName(); return a->GetName() < b->GetName();
} }
static void AuthorityTimerHandler(void) void ApiListener::UpdateObjectAuthority(void)
{ {
Zone::Ptr my_zone = Zone::GetLocalZone(); Zone::Ptr my_zone = Zone::GetLocalZone();
@ -80,16 +80,11 @@ static void AuthorityTimerHandler(void)
} }
} }
void ApiListener::UpdateObjectAuthorityAsync(void)
{
l_AuthorityTimer->Reschedule(0);
}
static void StaticInitialize(void) static void StaticInitialize(void)
{ {
l_AuthorityTimer = new Timer(); l_AuthorityTimer = new Timer();
l_AuthorityTimer->OnTimerExpired.connect(boost::bind(&AuthorityTimerHandler)); l_AuthorityTimer->OnTimerExpired.connect(boost::bind(&ApiListener::UpdateObjectAuthority));
l_AuthorityTimer->SetInterval(15); l_AuthorityTimer->SetInterval(30);
l_AuthorityTimer->Start(); l_AuthorityTimer->Start();
} }

View File

@ -19,6 +19,7 @@
#include "remote/configobjectutility.hpp" #include "remote/configobjectutility.hpp"
#include "remote/configpackageutility.hpp" #include "remote/configpackageutility.hpp"
#include "remote/apilistener.hpp"
#include "config/configcompiler.hpp" #include "config/configcompiler.hpp"
#include "config/configitem.hpp" #include "config/configitem.hpp"
#include "base/configwriter.hpp" #include "base/configwriter.hpp"
@ -149,6 +150,8 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full
return false; return false;
} }
ApiListener::UpdateObjectAuthority();
} catch (const std::exception& ex) { } catch (const std::exception& ex) {
delete expr; delete expr;