Skip to content
Snippets Groups Projects
Commit 6f3ce53e authored by abat's avatar abat
Browse files

Merge into master from pull request #1820: Fix NPE...

Merge into master from pull request #1820: Fix NPE (https://github.com/bigswitch/bigswitchcontroller/pull/1820)
parents 4995bb46 b8d1c056
No related branches found
No related tags found
No related merge requests found
......@@ -1155,41 +1155,44 @@ public class Controller implements IFloodlightProviderService,
}
if (shouldHandleMessage) {
sw.getListenerReadLock().lock();
try {
if (sw.isConnected()) {
if (!state.hsState.equals(HandshakeState.READY)) {
log.debug("Ignoring message type {} received " +
"from switch {} before switch is " +
"fully configured.", m.getType(), sw);
}
// Check if the controller is in the slave role for the
// switch. If it is, then don't dispatch the message to
// the listeners.
// TODO: Should we dispatch messages that we expect to
// receive when we're in the slave role, e.g. port
// status messages? Since we're "hiding" switches from
// the listeners when we're in the slave role, then it
// seems a little weird to dispatch port status messages
// to them. On the other hand there might be special
// modules that care about all of the connected switches
// and would like to receive port status notifications.
else if (sw.getRole() == Role.SLAVE) {
// Don't log message if it's a port status message
// since we expect to receive those from the switch
// and don't want to emit spurious messages.
if (m.getType() != OFType.PORT_STATUS) {
log.debug("Ignoring message type {} received " +
"from switch {} while in the slave role.",
m.getType(), sw);
// WARNING: sw is null if handshake is not complete
if (!state.hsState.equals(HandshakeState.READY)) {
log.debug("Ignoring message type {} received " +
"from switch {} before switch is " +
"fully configured.", m.getType(), sw);
} else {
sw.getListenerReadLock().lock();
try {
if (sw.isConnected()) {
// Check if the controller is in the slave role for the
// switch. If it is, then don't dispatch the message to
// the listeners.
// TODO: Should we dispatch messages that we expect to
// receive when we're in the slave role, e.g. port
// status messages? Since we're "hiding" switches from
// the listeners when we're in the slave role, then it
// seems a little weird to dispatch port status messages
// to them. On the other hand there might be special
// modules that care about all of the connected switches
// and would like to receive port status notifications.
if (sw.getRole() == Role.SLAVE) {
// Don't log message if it's a port status message
// since we expect to receive those from the switch
// and don't want to emit spurious messages.
if (m.getType() != OFType.PORT_STATUS) {
log.debug("Ignoring message type {} received " +
"from switch {} while in the slave role.",
m.getType(), sw);
}
} else {
handleMessage(sw, m, null);
}
} else {
handleMessage(sw, m, null);
}
}
}
finally {
sw.getListenerReadLock().unlock();
finally {
sw.getListenerReadLock().unlock();
}
}
}
}
......
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