ONOS-6052
Change-Id: I8fb42d86fad6914cf61d309dffe20f8c348b902a
(cherry picked from commit 18f7ca959c65c564da752e3e2d3d7271a75c2c28)
diff --git a/incubator/net/src/main/java/org/onosproject/incubator/net/dpi/impl/DpiStatisticsManager.java b/incubator/net/src/main/java/org/onosproject/incubator/net/dpi/impl/DpiStatisticsManager.java
index 23cb8b8..5ced9f5 100644
--- a/incubator/net/src/main/java/org/onosproject/incubator/net/dpi/impl/DpiStatisticsManager.java
+++ b/incubator/net/src/main/java/org/onosproject/incubator/net/dpi/impl/DpiStatisticsManager.java
@@ -123,8 +123,7 @@
@Deactivate
public void deactivate() {
log.info("Deactivated...");
- dpiStatisticsListener.stop();
- dpiListenerThread.shutdown();
+ dpiListenerThread.shutdownNow();
log.info("Stopped");
}
@@ -377,29 +376,6 @@
receiveDpiResult();
}
- public void stop() {
- try {
- if (serverSocket != null) {
- if (clientSocket != null) {
- if (in != null) {
- in.close();
- }
- if (out != null) {
- out.close();
- }
- clientSocket.close();
- //log.debug("DpiResultListener: stop(): Socket close() is done...");
- }
- serverSocket.close();
- //log.debug("DpiResultListener: stop(): Server close() is done...");
- }
- } catch (Exception e) {
- log.error("DpiStatisticsListener: stop(): Server Socket closing error, exception={}",
- e.toString());
- }
- log.debug("DpiStatisticsListener: stop(): stopped...");
- }
-
private void receiveDpiResult() {
try {
serverSocket = new ServerSocket(port);
@@ -410,7 +386,7 @@
}
try {
- while (true) {
+ while (!Thread.currentThread().isInterrupted()) {
if (clientSocket == null) {
log.info("DpiStatisticsListener: Waiting for accepting from dpi client...");
clientSocket = serverSocket.accept();
@@ -450,6 +426,26 @@
} catch (Exception e) {
log.error("DpiStatisticsListener: Exception = {}", e.toString());
return;
+ } finally {
+ try {
+ if (serverSocket != null) {
+ if (clientSocket != null) {
+ if (in != null) {
+ in.close();
+ }
+ if (out != null) {
+ out.close();
+ }
+ clientSocket.close();
+ //log.debug("DpiResultListener: stop(): Socket close() is done...");
+ }
+ serverSocket.close();
+ //log.debug("DpiResultListener: stop(): Server close() is done...");
+ }
+ } catch (Exception e) {
+ log.error("DpiStatisticsListener: stop(): Server Socket closing error, exception={}",
+ e.toString());
+ }
}
}