From: Baptiste Daroussin Date: Fri, 14 Apr 2023 11:13:20 +0000 (+0200) Subject: listcontrol: reduce I/O when rejecting a subscription X-Git-Tag: RELEASE_1_4_0b1~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ac4cdabeac804f17fd66ea96dd8edcff8af4233;p=thirdparty%2Fmlmmj.git listcontrol: reduce I/O when rejecting a subscription --- diff --git a/src/listcontrol.c b/src/listcontrol.c index cedceac3..e5c2922f 100644 --- a/src/listcontrol.c +++ b/src/listcontrol.c @@ -518,24 +518,23 @@ permit: /* listname+obstruct-COOKIE@domain.tld */ case CTRL_OBSTRUCT: xasprintf(&gatekeepfilename, "moderation/subscribe%s", param); - if (faccessat(ml->fd, gatekeepfilename, F_OK, 0) < 0) { + if (unlinkat(ml->fd, gatekeepfilename, 0) != 0) { + if (errno == ENOENT) { + errno = 0; + log_error(LOG_ARGS, "An obstruct request was" + " sent with a mismatching cookie." + " Ignoring mail"); + } else { + log_error(LOG_ARGS, "Could not unlink %s/%s", + ml->dir, gatekeepfilename); + } + free(param); free(gatekeepfilename); - /* no mail to moderate */ - errno = 0; - log_error(LOG_ARGS, "An obstruct request was" - " sent with a mismatching cookie." - " Ignoring mail"); return -1; } log_oper(ml->fd, OPLOGFNAME, "%s obstructed %s", tll_front(*fromemails), param); free(param); - if (unlinkat(ml->fd, gatekeepfilename, 0) != 0) { - log_error(LOG_ARGS, "Could not unlink %s/%s", - ml->dir, gatekeepfilename); - free(gatekeepfilename); - exit(EXIT_FAILURE); - } free(gatekeepfilename); break;