Check write lock only when db is busy 26/203426/4
authorSangyoon Jang <jeremy.jang@samsung.com>
Fri, 12 Apr 2019 10:49:59 +0000 (19:49 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Mon, 15 Apr 2019 02:38:29 +0000 (11:38 +0900)
Change-Id: I6f1048a7fc256223b87bda16d2454e3de84d25f4
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
parser/src/pkgmgr_parser_db.c

index 754b95b..3d79e4c 100644 (file)
@@ -433,6 +433,7 @@ static void __check_db_lock(const char *dbpath)
        FILE *fp;
        FILE *fp_cmdline;
        struct stat sb;
+       char type[BUFSIZE];
        int pid;
        unsigned int maj;
        unsigned int min;
@@ -452,10 +453,11 @@ static void __check_db_lock(const char *dbpath)
                return;
        }
 
-       while (fscanf(fp, "%*s %*s %*s %*s %d %x:%x:%lu %*s %*s",
-                               &pid, &maj, &min, &ino) != EOF) {
+       while (fscanf(fp, "%*s %*s %*s %5s %d %x:%x:%lu %*s %*s",
+                               type, &pid, &maj, &min, &ino) != EOF) {
                if (maj != major(sb.st_dev) || min != minor(sb.st_dev) ||
-                               ino != sb.st_ino || pid == getpid())
+                               ino != sb.st_ino || pid == getpid() ||
+                               strcasecmp(type, "WRITE"))
                        continue;
 
                snprintf(cmdline, sizeof(cmdline), "/proc/%d/cmdline", pid);