rimmed pushed a commit to branch master.

http://git.enlightenment.org/tools/eflete.git/commit/?id=efad8510bd0164f5e69c9865ecbd40533f603148

commit efad8510bd0164f5e69c9865ecbd40533f603148
Author: Yeongjong Lee <[email protected]>
Date:   Fri Oct 6 11:50:23 2017 +0300

    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
---
 src/bin/project_manager/project_manager2.c | 29 ++---------------------------
 1 file changed, 2 insertions(+), 27 deletions(-)

diff --git a/src/bin/project_manager/project_manager2.c 
b/src/bin/project_manager/project_manager2.c
index 4672aaaa7..772f738cb 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)
    lf = fopen(lock_file, "r");
    if (!lf)
      {
+        ERR(" %s\n", strerror(errno));
         return PM_PROJECT_LOCKED_PERMISSION;
      }
    if (fscanf(lf, "%i", &pid) <= 0)
@@ -564,10 +565,8 @@ _project_lock_pid_check(const char *lock_file)
 static PM_Project_Result
 _project_trylock(const char *pro_path)
 {
-   int fd;
    char *dir;
    char path[PATH_MAX];
-   PM_Project_Result ret = true;
 
    assert(path != NULL);
 
@@ -579,31 +578,7 @@ _project_trylock(const char *pro_path)
         return _project_lock_pid_check(path);
      }
 
-   fd = open(path, O_RDWR);
-   if (fd < 1)
-     {
-        ERR(" %s\n", strerror(errno));
-        return PM_PROJECT_LOCKED_PERMISSION;
-     }
-
-#ifndef _WIN32
-   struct flock fl;
-   fl.l_type = F_UNLCK;
-   fl.l_whence = SEEK_SET;
-   fl.l_start = 0;
-   fl.l_len = 0;
-   fl.l_pid = 0;
-   if (fcntl(fd, F_GETLK, &fl) != -1)
-     {
-        if (fl.l_type != F_UNLCK)
-          ret = PM_PROJECT_LOCKED_PERMISSION;
-     }
-   else
-     ret = PM_PROJECT_LOCKED_PERMISSION;
-#endif /* _WIN32 */
-
-   close(fd);
-   return ret;
+   return PM_PROJECT_SUCCESS;
 }
 
 static Eina_Bool

-- 


Reply via email to