Skip to content
Snippets Groups Projects
Commit 88fb52f3 authored by Rob Adams's avatar Rob Adams
Browse files

Don't set role again if it's the same. Partial fix for BSC-1835

parent 82b4a63d
No related branches found
No related tags found
No related merge requests found
...@@ -345,12 +345,14 @@ public class Controller implements IFloodlightProviderService, ...@@ -345,12 +345,14 @@ public class Controller implements IFloodlightProviderService,
} }
@Override @Override
public synchronized Role getRole() { public Role getRole() {
return role; synchronized(roleChanger) {
return role;
}
} }
@Override @Override
public synchronized void setRole(Role role) { public void setRole(Role role) {
if (role == null) throw new NullPointerException("Role can not be null."); if (role == null) throw new NullPointerException("Role can not be null.");
// Need to synchronize to ensure a reliable ordering on role request // Need to synchronize to ensure a reliable ordering on role request
...@@ -359,6 +361,11 @@ public class Controller implements IFloodlightProviderService, ...@@ -359,6 +361,11 @@ public class Controller implements IFloodlightProviderService,
// timeout handling // timeout handling
// @see RoleChanger // @see RoleChanger
synchronized(roleChanger) { synchronized(roleChanger) {
if (role.equals(this.role)) {
log.debug("Ignoring role change: role is already {}", role);
return;
}
Role oldRole = this.role; Role oldRole = this.role;
this.role = role; this.role = role;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment