From 45a12ad5a174ca4f44d5727d1a46e80536d052f5 Mon Sep 17 00:00:00 2001 From: "hyeran74.kim" Date: Tue, 2 Sep 2014 13:51:56 +0900 Subject: [PATCH] File : deal with if there is no releasing file locked when closing the file Change-Id: If24fae9fed1bdb5651c062cdfbce7c68e76ac464 Signed-off-by: hyeran74.kim --- .../org/tizen/dynamicanalyzer/common/DALimit.java | 4 +- .../swap/communicator/Communicator30.java | 6 +- .../ui/file/manager/FileDataMaker.java | 68 +++++++++++----------- 3 files changed, 38 insertions(+), 40 deletions(-) diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/DALimit.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/DALimit.java index 1e895b2..6ba68f8 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/DALimit.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/DALimit.java @@ -59,7 +59,7 @@ public class DALimit { public static final int MAX_LEAK_CHECK_BUFFER_SIZE = (int) Math.pow(2, 20); // 1,048,576 // File Analysis - public static final int MAX_FILE_STATUS_COUNT = (int) Math.pow(2, 10); // 102400 - public static final int MAX_FILE_ACCESS_COUNT =(int) Math.pow(2, 10); // 102400 + public static final int MAX_FILE_STATUS_COUNT = ((int) Math.pow(2, 10))*100; // 102400 // 102400 + public static final int MAX_FILE_ACCESS_COUNT = ((int) Math.pow(2, 10))*100; // 102400 // 102400 public static final int MAX_STRING_LENGTH = 12; } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/communicator/Communicator30.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/communicator/Communicator30.java index 265eb03..b39b9f0 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/communicator/Communicator30.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/communicator/Communicator30.java @@ -360,9 +360,9 @@ public class Communicator30 extends BaseCommunicator { } else if (appType.contains(AppInfo.APPTYPE_WEB)) { appInst.setApplicationType(ApplicationInst.APPTYPE_WEB); appInst.setApplicationId(app.getAppId()); -// } else if (appType.contains(AppInfo.APPTYPE_CAPP)) { -// appInst.setApplicationType(ApplicationInst.APPTYPE_TIZEN); -// appInst.setApplicationId(app.getAppId()); + } else if (appType.contains(AppInfo.APPTYPE_CAPP)) { + appInst.setApplicationType(ApplicationInst.APPTYPE_TIZEN); + appInst.setApplicationId(app.getAppId()); } else { appInst.setApplicationType(ApplicationInst.APPTYPE_COMMON_EXEC); appInst.setApplicationId(CommonConstants.EMPTY); diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/manager/FileDataMaker.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/manager/FileDataMaker.java index f143984..13f2da4 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/manager/FileDataMaker.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/file/manager/FileDataMaker.java @@ -80,8 +80,6 @@ public class FileDataMaker { private Queue> fileLogsQueue = new ConcurrentLinkedQueue>(); // (key(file path), value (read_count or write_count)) - private Map concurrentReadNumMap = new HashMap(); - private Map concurrentWriteNumMap = new HashMap(); private Map concurrentAccessNumMap = new HashMap(); private Map lockNumMap = new HashMap(); private List> lockWaitingAccessor = new ArrayList>(); @@ -95,20 +93,19 @@ public class FileDataMaker { // for searching entry message from exit message Map entryMap = new HashMap(); - // temp - private List sentOpenEventList = new ArrayList(); - public FileDataMaker() {} public void clear(){ fileStatusList.clear(); fileAccessList.clear(); fileAccessorMap.clear(); - concurrentReadNumMap.clear(); - concurrentWriteNumMap.clear(); + concurrentAccessNumMap.clear(); + lockNumMap.clear(); + lockWaitingAccessor.clear(); sysCallMap.clear(); accessedFilePathList.clear(); entryMap.clear(); + sysLockedFd.clear(); } public void makeData(LogPackage pack) { @@ -155,32 +152,22 @@ public class FileDataMaker { SummaryDataManager.getInstance().getFailedApiDataMaker().makeData(input); } - long fd = input.getFdValue(); if(input.getFdApiType() == LogCenterConstants.FD_API_TYPE_OPEN){ accessedFilePathList.add(input.getFilePath()); - // TODO temp code - sentOpenEventList.add(fd); - } - - Logger.debug(">>probe pid:" + input.getPid() - + ", tid:" + input.getTid() + ", fd:" + input.getFdValue() - + ", type:" + input.getFdApiType() - + ", filePath:" + input.getFilePath() + ", err:" + input.getErrno() ); - - if(sentOpenEventList.contains(fd)) { - event = new FileEvent(input.getSeq(), input.getFilePath(), - input.getPid(), input.getTid(), input.getFdValue(), - input.getFdApiType(), input.getApiId(), - input.getTime(), input.getFileSize(), input.getSize(), - input.getArgs(), input.getReturn(), input.getErrno(), - true); - addFileEvent(fileEventList, event, input); } - // TODO temp code - if (input.getFdApiType() == LogCenterConstants.FD_API_TYPE_CLOSE) { - sentOpenEventList.remove(fd); - } + Logger.debug(">>probe pid:" + input.getPid() + ", tid:" + + input.getTid() + ", fd:" + input.getFdValue() + + ", type:" + input.getFdApiType() + ", filePath:" + + input.getFilePath() + ", err:" + input.getErrno()); + + event = new FileEvent(input.getSeq(), input.getFilePath(), + input.getPid(), input.getTid(), input.getFdValue(), + input.getFdApiType(), input.getApiId(), + input.getTime(), input.getFileSize(), input.getSize(), + input.getArgs(), input.getReturn(), input.getErrno(), + true); + addFileEvent(fileEventList, event, input); } } @@ -201,10 +188,7 @@ public class FileDataMaker { int tid = profileData.getTid(); long time = profileData.getTime(); int eventType = profileData.getProbeSubType(); - - Logger.debug(">> syscall:seq:" + seq + ", pid:" + pid - + ", tid:" + tid + ", type:" + eventType ); - + switch (profileData.getId()) { case DataChannelConstants.MSG_FUNCTION_ENTRY: // get file path and FD from args : string of "file_path,fd" @@ -362,6 +346,12 @@ public class FileDataMaker { } addStatusData(new FileStatus(pid, tid, fd, filePath, apiType, eventTime, errNo)); + // if it remains lock without lock release + if(getCurrentLockNum(filePath) > 0) { + removeLockNum(filePath); + addEndAccessData(pid, tid, fd, filePath, eventTime, size, + LogCenterConstants.FD_API_TYPE_LOCK_START, errNo); + } break; case LogCenterConstants.FD_API_TYPE_READ_START: FileAccess readAccess = new FileAccess(filePath, pid, @@ -416,7 +406,7 @@ public class FileDataMaker { removeConcurrentAccess(filePath); break; case LogCenterConstants.FD_API_TYPE_LOCK_START: - if(getCurrentLockNum(filePath) > 0) { + if(addCurrentLock(filePath) > 0) { addLockWaitingAccessor(pid, tid); addStartAccessData(new FileAccess(filePath, pid, tid, fd, LogCenterConstants.FD_API_TYPE_LOCK_WAIT_START, eventTime)); @@ -556,7 +546,7 @@ public class FileDataMaker { } } - private int getCurrentLockNum(String lockKey) { + private int addCurrentLock(String lockKey) { int num = 0; if(lockNumMap.containsKey(lockKey)) { num = lockNumMap.get(lockKey); @@ -566,6 +556,14 @@ public class FileDataMaker { return num; } + private int getCurrentLockNum(String lockKey) { + int num = 0; + if(lockNumMap.containsKey(lockKey)) { + num = lockNumMap.get(lockKey); + } + return num; + } + private void removeLockNum(String lockKey) { int num = 0; if(lockNumMap.containsKey(lockKey)) { -- 2.7.4