fixed #229: handling rapid switch flapping race conditions gracefully
diff --git a/src/main/java/net/floodlightcontroller/core/internal/Controller.java b/src/main/java/net/floodlightcontroller/core/internal/Controller.java
index 4057bc9..60dbc69 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/Controller.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/Controller.java
@@ -797,6 +797,7 @@
}
protected void checkSwitchReady() {
+ Boolean controlRequested = Boolean.TRUE;
if (state.hsState == HandshakeState.FEATURES_REPLY &&
state.hasDescription && state.hasGetConfigReply) {
@@ -825,6 +826,7 @@
new RoleChangeCallback());
} catch (RegistryException e) {
log.debug("Registry error: {}", e.getMessage());
+ controlRequested = Boolean.FALSE;
}
@@ -858,6 +860,16 @@
state.firstRoleReplyReceived = true;
}
}
+ if (!controlRequested) {
+ // yield to allow other thread(s) to release control
+ try {
+ Thread.sleep(10);
+ } catch (InterruptedException e) {
+ // Ignore interruptions
+ }
+ // safer to bounce the switch to reconnect here than proceeding further
+ sw.channel.close();
+ }
}
}