MISC: change stop policy when application is terminated from target
authorgreatim <jaewon81.lim@samsung.com>
Wed, 22 Jul 2015 07:12:28 +0000 (16:12 +0900)
committergreatim <jaewon81.lim@samsung.com>
Wed, 22 Jul 2015 07:12:28 +0000 (16:12 +0900)
change stop policy when application is terminated from target
 - by now, user must push the stop button to stop the trace

Change-Id: I3c95a2f4126cfc47f3af65abc98441480bf5af2d
Signed-off-by: greatim <jaewon81.lim@samsung.com>
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerConstants.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerManager.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/protocol/p30/Communicator30.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/communicator/DataChannelThread.java

index c4dd84c..1755754 100644 (file)
@@ -112,11 +112,11 @@ public class AnalyzerConstants {
        public static final int THREAD_SLEEP_INTERVAL = 100; // 100 ms interval for thread polling
 
        /* timeout value */
-       public static final int DATA_SOCKET_INTERRUPT_INTERVAL = 500; // 0.5 sec for interruption check
+       public static final int DATA_SOCKET_INTERRUPT_INTERVAL = 1000; // 1 sec for interruption check
        public static final int DATA_SOCKET_TIMEOUT_NORMAL = 10000; // 10 second
        public static final int DATA_SOCKET_TIMEOUT_TERMINATE = 3000; // 3 second
        public static final int DATA_SOCKET_TIMEOUT_CLEAR = 10; // 10 ms
-       public static final int CONTROL_SOCKET_TIMEOUT = 10000; // 10 second
+       public static final int CONTROL_SOCKET_TIMEOUT = 20000; // 20 second
        public static final int PROC_ADD_INFO_TIMEOUT = 1000;
 
        /* timer intervals */
index 5f9223f..82c9c13 100755 (executable)
@@ -47,6 +47,7 @@ public class AnalyzerManager {
        private static boolean processInfoArrived = false;
        private static boolean terminateMsgArrived = false; // set by message parser
        private static boolean dataSocketClosed = false; // set by data channel thread
+       private static boolean stopAckArrived = false; // set by control channel
 
        private static NewLeakDetector newLeakDetector = new NewLeakDetector();
        private static WarningChecker warningChecker = new WarningChecker();
@@ -91,6 +92,14 @@ public class AnalyzerManager {
                dataSocketClosed = closed;
        }
 
+       public static boolean isStopAckArrived() {
+               return stopAckArrived;
+       }
+
+       public static void setStopAckArrived(boolean arrived) {
+               stopAckArrived = arrived;
+       }
+
        public static NewLeakDetector getNewLeakDetector() {
                return newLeakDetector;
        }
@@ -102,6 +111,7 @@ public class AnalyzerManager {
        public static void clear() {
                processInfoArrived = false;
                terminateMsgArrived = false;
+               stopAckArrived = false;
 
                newLeakDetector.clear();
                warningChecker.clear();
index 769da1f..a585726 100644 (file)
@@ -503,6 +503,7 @@ public class Communicator30 extends SubCommunicator {
                AckMessage result = parent.handleControlMessage(msg);
                if (result != null && result.isSuccess()
                                && result.isCorrectID(ProtocolConstant30.MSG_STOP_ACK)) {
+                       AnalyzerManager.setStopAckArrived(true);
                        return new DAResult(ErrorCode.SUCCESS);
                } else {
                        return new DAResult(ErrorCode.ERR_MSG_STOP_FAIL);
index 7b7559b..f442aa6 100644 (file)
@@ -303,6 +303,11 @@ public class DataChannelThread extends DataThread<Object> {
                                        throw new InterruptedIOException();
                                }
 
+                               // check if stop ack arrived
+                               if (AnalyzerManager.isStopAckArrived()) {
+                                       throw new SocketTimeoutException();
+                               }
+
                                // check the real timeout for socket
                                if (timeoutValue >= socketTimeout) {
                                        throw e;
@@ -347,12 +352,16 @@ public class DataChannelThread extends DataThread<Object> {
                        if (Global.getProject().getActiveProcessCount() == 0) {
                                // if there is no active process, no more message from target
                                AnalyzerManager.setTerminateMsgArrived(true);
-                               // exit data channel thread
-                               return true;
                        }
                }
 
-               return false;
+               // exit data channel thread only if ensure stop ack is arrived
+               // that means there is no more data to received by data channel
+               if (AnalyzerManager.isStopAckArrived()) {
+                       return true;
+               } else {
+                       return false;
+               }
        }
 
        private void notifyStopWork(final DAResult result, final boolean stopFromTarget) {