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;
}
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
}
private void reportError(Exception e) {
- logger.debug("Caught exception ", e);
+ if (e instanceof AsynchronousCloseException) {
+ logger.debug("Caught exception {}", e.getMessage());
+ } else {
+ logger.warn("Caught exception {}", e.getMessage());
+ }
// notify core of this error event and disconnect the switch
((Controller) core).takeSwitchEventError(this);
}
*/
class PriorityMessageTransmit implements Runnable {
public void run() {
- while (true) {
+ running = true;
+ while (running) {
try {
if (!transmitQ.isEmpty()) {
PriorityMessage pmsg = transmitQ.poll();
reportError(e);
}
}
+ transmitQ = null;
}
}
}
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);