X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fprotocol_plugins%2Fopenflow%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fprotocol_plugin%2Fopenflow%2Fcore%2Finternal%2FSwitchHandler.java;h=78ab3275a4ac674333f8b4cb26464b61488d2cda;hp=b87b785e3c1aa8f0d855c12208bba8088a421cf1;hb=a409fe492f53dd811259c11f0cde4f8771f269ad;hpb=889a586b7db63f36ea608caa54bba8d7a222ef45 diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SwitchHandler.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SwitchHandler.java index b87b785e3c..78ab3275a4 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SwitchHandler.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/core/internal/SwitchHandler.java @@ -9,6 +9,7 @@ package org.opendaylight.controller.protocol_plugin.openflow.core.internal; +import java.io.IOException; import java.nio.channels.AsynchronousCloseException; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; @@ -186,17 +187,33 @@ public class SwitchHandler implements ISwitch { } public void stop() { - try { - running = false; - selector.wakeup(); - cancelSwitchTimer(); - this.selector.close(); - this.socket.close(); - executor.shutdown(); - } catch (Exception e) { - // do nothing since we are shutting down. - return; - } + running = false; + cancelSwitchTimer(); + try { + selector.wakeup(); + selector.close(); + } catch (Exception e) { + } + try { + socket.close(); + } catch (Exception e) { + } + try { + msgReadWriteService.stop(); + } catch (Exception e) { + } + executor.shutdown(); + + selector = null; + socket = null; + msgReadWriteService = null; + + if (switchHandlerThread != null) { + switchHandlerThread.interrupt(); + } + if (transmitThread != null) { + transmitThread.interrupt(); + } } @Override @@ -713,7 +730,8 @@ public class SwitchHandler implements ISwitch { */ class PriorityMessageTransmit implements Runnable { public void run() { - while (true) { + running = true; + while (running) { try { if (!transmitQ.isEmpty()) { PriorityMessage pmsg = transmitQ.poll(); @@ -725,6 +743,7 @@ public class SwitchHandler implements ISwitch { reportError(e); } } + transmitQ = null; } } @@ -762,7 +781,7 @@ public class SwitchHandler implements ISwitch { } private IMessageReadWrite getMessageReadWriteService() throws Exception { - String str = System.getProperty("secureChannelEnabled"); + String str = System.getProperty("secureChannelEnabled").trim(); return ((str != null) && (str.equalsIgnoreCase("true"))) ? new SecureMessageReadWriteService(socket, selector) : new MessageReadWriteService(socket, selector);