]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
listcontrol: reduce I/O when rejecting a moderated message
authorBaptiste Daroussin <bapt@FreeBSD.org>
Fri, 14 Apr 2023 09:43:59 +0000 (11:43 +0200)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Fri, 14 Apr 2023 09:43:59 +0000 (11:43 +0200)
src/listcontrol.c

index 8cf9fe7b0cdfd321ad78f45612e700a9549ed9cc..7049b2484e64afe1be200ad0b75c46411d80181d 100644 (file)
@@ -485,23 +485,21 @@ int listcontrol(strlist *fromemails, struct ml *ml,
        /* listname+reject-COOKIE@domain.tld */
        case CTRL_REJECT:
                xasprintf(&moderatefilename, "moderation/%s", param);
-               if (faccessat(ml->fd, moderatefilename, F_OK, 0) < 0) {
+               if (unlinkat(ml->fd, moderatefilename, 0) != 0) {
+                       if (errno == ENOENT) {
+                               errno = 0;
+                               log_error(LOG_ARGS, "A reject request was"
+                                       " sent with a mismatching cookie."
+                                       " Ignoring mail");
+                       } else {
+                               log_error(LOG_ARGS, "Could not unlink %s",
+                                   moderatefilename);
+                       }
                        free(moderatefilename);
-                       /* no mail to moderate */
-                       errno = 0;
-                       log_error(LOG_ARGS, "A reject request was"
-                               " sent with a mismatching cookie."
-                               " Ignoring mail");
                        return -1;
                }
                log_oper(ml->fd, OPLOGFNAME, "%s rejected %s",
                        tll_front(*fromemails), param);
-               if (unlinkat(ml->fd, moderatefilename, 0) != 0) {
-                       log_error(LOG_ARGS, "Could not unlink %s",
-                                       moderatefilename);
-                       free(moderatefilename);
-                       exit(EXIT_FAILURE);
-               }
                free(moderatefilename);
                xasprintf(&moderatefilename, "moderation/%s.omit", param);
                unlinkat(ml->fd, moderatefilename, 0);