From: Baptiste Daroussin Date: Fri, 14 Apr 2023 09:43:59 +0000 (+0200) Subject: listcontrol: reduce I/O when rejecting a moderated message X-Git-Tag: RELEASE_1_4_0b1~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=950c76f7c9f7a04e23610b9c8ccedec878b6341f;p=thirdparty%2Fmlmmj.git listcontrol: reduce I/O when rejecting a moderated message --- diff --git a/src/listcontrol.c b/src/listcontrol.c index 8cf9fe7b..7049b248 100644 --- a/src/listcontrol.c +++ b/src/listcontrol.c @@ -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);