changeset 1595:fc1fbedc3d4e HEAD

some more cleanups
author Timo Sirainen <tss@iki.fi>
date Thu, 03 Jul 2003 04:01:10 +0300
parents 94df30426a96
children beab37ab1617
files src/lib/unlink-lockfiles.c src/lib/unlink-lockfiles.h
diffstat 2 files changed, 8 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/unlink-lockfiles.c	Thu Jul 03 03:58:42 2003 +0300
+++ b/src/lib/unlink-lockfiles.c	Thu Jul 03 04:01:10 2003 +0300
@@ -44,12 +44,8 @@
 
 	/* 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 @@
 			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 @@
 			    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;
 }
--- a/src/lib/unlink-lockfiles.h	Thu Jul 03 03:58:42 2003 +0300
+++ b/src/lib/unlink-lockfiles.h	Thu Jul 03 04:01:10 2003 +0300
@@ -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);