From: Richard Mortimer Date: Tue, 25 Jan 2011 16:35:25 +0000 (+0000) Subject: Only stat files after discounting ignored filenames. X-Git-Tag: RELEASE_1_2_18a1~45 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5b9f532e6148d6f21381bbcb910a392a1dc387d7;p=thirdparty%2Fmlmmj.git Only stat files after discounting ignored filenames. This eliminates confusing log messages similar to mlmmj-maintd.c:511: Could not stat(auser=example.com.lastmsg): No such file or directory These occur when bouncing users are unsubscribed because the .lastmsg files are checked after the auser=example.com files with no extensions. --- diff --git a/src/mlmmj-maintd.c b/src/mlmmj-maintd.c index 422d630b..b986fcf1 100644 --- a/src/mlmmj-maintd.c +++ b/src/mlmmj-maintd.c @@ -521,14 +521,16 @@ int clean_nolongerbouncing(const char *listdir) (strcmp(dp->d_name, ".") == 0)) continue; - if(stat(dp->d_name, &st) < 0) { - log_error(LOG_ARGS, "Could not stat(%s)", dp->d_name); - continue; - } - filename = mystrdup(dp->d_name); if((s = strstr(filename, "-probe"))) { + if(stat(filename, &st) < 0) { + log_error(LOG_ARGS, "Could not stat(%s)", + filename); + myfree(filename); + continue; + } + probefd = open(filename, O_RDONLY); if(probefd < 0) continue; @@ -586,11 +588,6 @@ int probe_bouncers(const char *listdir, const char *mlmmjbounce) (strcmp(dp->d_name, ".") == 0)) continue; - if(stat(dp->d_name, &st) < 0) { - log_error(LOG_ARGS, "Could not stat(%s)", dp->d_name); - continue; - } - if(strstr(dp->d_name, "-probe")) continue; @@ -598,6 +595,11 @@ int probe_bouncers(const char *listdir, const char *mlmmjbounce) if(s && (strcmp(s, ".lastmsg") == 0)) continue; + if(stat(dp->d_name, &st) < 0) { + log_error(LOG_ARGS, "Could not stat(%s)", dp->d_name); + continue; + } + probefile = concatstr(2, dp->d_name, "-probe"); /* Skip files which already have a probe out */ @@ -675,11 +677,6 @@ int unsub_bouncers(const char *listdir, const char *mlmmjunsub) (strcmp(dp->d_name, ".") == 0)) continue; - if(stat(dp->d_name, &st) < 0) { - log_error(LOG_ARGS, "Could not stat(%s)", dp->d_name); - continue; - } - if(strstr(dp->d_name, "-probe")) continue; @@ -687,6 +684,11 @@ int unsub_bouncers(const char *listdir, const char *mlmmjunsub) if(a && (strcmp(a, ".lastmsg") == 0)) continue; + if(stat(dp->d_name, &st) < 0) { + log_error(LOG_ARGS, "Could not stat(%s)", dp->d_name); + continue; + } + probefile = concatstr(2, dp->d_name, "-probe"); /* Skip files which already have a probe out */