/* 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);
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 &&
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;
}
/* 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);