]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
Only stat files after discounting ignored filenames.
authorRichard Mortimer <none@none>
Tue, 25 Jan 2011 16:35:25 +0000 (16:35 +0000)
committerRichard Mortimer <none@none>
Tue, 25 Jan 2011 16:35:25 +0000 (16:35 +0000)
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.

src/mlmmj-maintd.c

index 422d630b6b3211dd3f74f57a5665fb2457a94c3a..b986fcf1d0cdeb2e99c4b284da172b55d65b92d8 100644 (file)
@@ -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 */