]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
some more cleanups
authorTimo Sirainen <tss@iki.fi>
Thu, 3 Jul 2003 01:01:10 +0000 (04:01 +0300)
committerTimo Sirainen <tss@iki.fi>
Thu, 3 Jul 2003 01:01:10 +0000 (04:01 +0300)
--HG--
branch : HEAD

src/lib/unlink-lockfiles.c
src/lib/unlink-lockfiles.h

index 71779eaf843f4000750770cc5144889bab3f8f7c..333c6842ab7ce663f1b0fa4a93b31d8076f67117 100644 (file)
@@ -44,12 +44,8 @@ int unlink_lockfiles(const char *dir, const char *pidprefix,
 
        /* check for any invalid access files */
        dirp = opendir(dir);
-       if (dirp == NULL) {
-               if (errno == ENOENT)
-                       return 0;
-               i_error("opendir(%s) failed: %m", dir);
+       if (dirp == NULL)
                return -1;
-       }
 
        pidlen = pidprefix == NULL ? 0 : strlen(pidprefix);
        otherlen = otherprefix == NULL ? 0 : strlen(otherprefix);
@@ -69,7 +65,7 @@ int unlink_lockfiles(const char *dir, const char *pidprefix,
                        if (str_path(path, sizeof(path), dir, fname) == 0) {
                                if (unlink(path) < 0 && errno != ENOENT) {
                                        i_error("unlink(%s) failed: %m", path);
-                                       ret = -1;
+                                       ret = 0;
                                }
                        }
                } else if (otherprefix != NULL &&
@@ -80,15 +76,13 @@ int unlink_lockfiles(const char *dir, const char *pidprefix,
                            st.st_ctime < other_min_time)
                                if (unlink(path) < 0 && errno != ENOENT) {
                                        i_error("unlink(%s) failed: %m", path);
-                                       ret = -1;
+                                       ret = 0;
                                }
                }
        }
 
-       if (closedir(dirp) < 0) {
+       if (closedir(dirp) < 0)
                i_error("closedir(%s) failed: %m", dir);
-               ret = -1;
-       }
 
        return ret;
 }
index 05eebc2cfed8fcd2420363a42f7d2e13c54107af..f8fdd6787c39654d27106333f19c8c980c0054ab 100644 (file)
@@ -4,7 +4,10 @@
 /* Delete stale lock files. Filenames beginning with pidprefix<PID> are
    deleted immediately if PID doesn't exist. Filenames beginning with
    otherprefix are deleted if their mtime and ctime is older than
-   other_min_time. */
+   other_min_time.
+
+   Returns 1 if everything was successful, 0 if some of the files
+   couldn't be deleted, -1 if directory couldn't be opened at all. */
 int unlink_lockfiles(const char *dir, const char *pidprefix,
                     const char *otherprefix, time_t other_min_time);