summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYeongjong Lee <cleanlyj@naver.com>2017-10-06 11:50:23 +0300
committerVyacheslav Reutskiy <v.reutskiy@samsung.com>2017-10-06 11:50:36 +0300
commitefad8510bd0164f5e69c9865ecbd40533f603148 (patch)
tree8d23b6dddf660ad0b2c8bab05fc1a0ae107d71c8
parent38ca994ec0c9552698cd80a6a0e5ec0949628224 (diff)
project manager: remove unnecessary codes of _trylock
Summary: _project_lock_pid_check can check lock permission, so it doesn't need to recheck about lock. actually the open function(open(path, O_RDWR);) always return -1, because the file always does not exist. (see line 567) also, this fixes bug that eflete can't open existing projects. Test Plan: 1. Create new project. 2. Close eflete successfully. 3. Open the project again. 4. Check that eflete can open the project. Reviewers: rimmed Reviewed By: rimmed Differential Revision: https://phab.enlightenment.org/D5259
-rw-r--r--src/bin/project_manager/project_manager2.c29
1 files changed, 2 insertions, 27 deletions
diff --git a/src/bin/project_manager/project_manager2.c b/src/bin/project_manager/project_manager2.c
index 4672aaa..772f738 100644
--- a/src/bin/project_manager/project_manager2.c
+++ b/src/bin/project_manager/project_manager2.c
@@ -532,6 +532,7 @@ _project_lock_pid_check(const char *lock_file)
532 lf = fopen(lock_file, "r"); 532 lf = fopen(lock_file, "r");
533 if (!lf) 533 if (!lf)
534 { 534 {
535 ERR(" %s\n", strerror(errno));
535 return PM_PROJECT_LOCKED_PERMISSION; 536 return PM_PROJECT_LOCKED_PERMISSION;
536 } 537 }
537 if (fscanf(lf, "%i", &pid) <= 0) 538 if (fscanf(lf, "%i", &pid) <= 0)
@@ -564,10 +565,8 @@ _project_lock_pid_check(const char *lock_file)
564static PM_Project_Result 565static PM_Project_Result
565_project_trylock(const char *pro_path) 566_project_trylock(const char *pro_path)
566{ 567{
567 int fd;
568 char *dir; 568 char *dir;
569 char path[PATH_MAX]; 569 char path[PATH_MAX];
570 PM_Project_Result ret = true;
571 570
572 assert(path != NULL); 571 assert(path != NULL);
573 572
@@ -579,31 +578,7 @@ _project_trylock(const char *pro_path)
579 return _project_lock_pid_check(path); 578 return _project_lock_pid_check(path);
580 } 579 }
581 580
582 fd = open(path, O_RDWR); 581 return PM_PROJECT_SUCCESS;
583 if (fd < 1)
584 {
585 ERR(" %s\n", strerror(errno));
586 return PM_PROJECT_LOCKED_PERMISSION;
587 }
588
589#ifndef _WIN32
590 struct flock fl;
591 fl.l_type = F_UNLCK;
592 fl.l_whence = SEEK_SET;
593 fl.l_start = 0;
594 fl.l_len = 0;
595 fl.l_pid = 0;
596 if (fcntl(fd, F_GETLK, &fl) != -1)
597 {
598 if (fl.l_type != F_UNLCK)
599 ret = PM_PROJECT_LOCKED_PERMISSION;
600 }
601 else
602 ret = PM_PROJECT_LOCKED_PERMISSION;
603#endif /* _WIN32 */
604
605 close(fd);
606 return ret;
607} 582}
608 583
609static Eina_Bool 584static Eina_Bool