More bugfixes.

This commit is contained in:
Gunnar Beutner 2012-06-21 13:31:58 +02:00
parent 628c782837
commit abd34bdaa0
2 changed files with 15 additions and 5 deletions

View File

@ -72,8 +72,12 @@ void DelegationComponent::AssignService(const Endpoint::Ptr& checker, const Serv
void DelegationComponent::AssignServiceResponseHandler(Service& service, const Endpoint::Ptr& sender, bool timedOut) void DelegationComponent::AssignServiceResponseHandler(Service& service, const Endpoint::Ptr& sender, bool timedOut)
{ {
/* ignore the message if it's not from the designated checker for this service */
if (!sender || service.GetChecker() != sender->GetIdentity())
return;
if (timedOut) { if (timedOut) {
Application::Log(LogDebug, "delegation", "Service delegation for service '" + service.GetName() + "' timed out."); Application::Log(LogInformation, "delegation", "Service delegation for service '" + service.GetName() + "' timed out.");
service.SetChecker(""); service.SetChecker("");
} }
} }
@ -136,6 +140,7 @@ void DelegationComponent::DelegationTimerHandler(void)
std::random_shuffle(services.begin(), services.end()); std::random_shuffle(services.begin(), services.end());
bool need_clear = false;
int delegated = 0; int delegated = 0;
/* re-assign services */ /* re-assign services */
@ -176,6 +181,7 @@ void DelegationComponent::DelegationTimerHandler(void)
/* clear the service's current checker */ /* clear the service's current checker */
if (!checker.empty()) { if (!checker.empty()) {
need_clear = true;
service.SetChecker(""); service.SetChecker("");
if (oldEndpoint) if (oldEndpoint)
@ -202,10 +208,14 @@ void DelegationComponent::DelegationTimerHandler(void)
} }
if (delegated > 0) { if (delegated > 0) {
// TODO: send clear message when session is established
// TODO: clear local assignments when session is lost
if (need_clear) {
map<Endpoint::Ptr, int>::iterator hit; map<Endpoint::Ptr, int>::iterator hit;
for (hit = histogram.begin(); hit != histogram.end(); hit++) { for (hit = histogram.begin(); hit != histogram.end(); hit++) {
ClearServices(hit->first); ClearServices(hit->first);
} }
}
for (sit = services.begin(); sit != services.end(); sit++) { for (sit = services.begin(); sit != services.end(); sit++) {
string checker = sit->GetChecker(); string checker = sit->GetChecker();

View File

@ -55,7 +55,7 @@ public:
void SendMulticastMessage(Endpoint::Ptr sender, const RequestMessage& message); void SendMulticastMessage(Endpoint::Ptr sender, const RequestMessage& message);
void SendAPIMessage(const Endpoint::Ptr& sender, const Endpoint::Ptr& recipient, RequestMessage& message, void SendAPIMessage(const Endpoint::Ptr& sender, const Endpoint::Ptr& recipient, RequestMessage& message,
function<void(const EndpointManager::Ptr&, const Endpoint::Ptr, const RequestMessage&, const ResponseMessage&, bool TimedOut)> callback, time_t timeout = 10); function<void(const EndpointManager::Ptr&, const Endpoint::Ptr, const RequestMessage&, const ResponseMessage&, bool TimedOut)> callback, time_t timeout = 30);
void ProcessResponseMessage(const Endpoint::Ptr& sender, const ResponseMessage& message); void ProcessResponseMessage(const Endpoint::Ptr& sender, const ResponseMessage& message);