From 77dc5d1730634ba7d115ca63e4ce937aa2466d5d Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sat, 30 Jan 2021 22:17:30 -0500 Subject: [PATCH] New listdeliver module (skeleton) --- .../modules/listdeliver/serv_listdeliver.c | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 citadel/modules/listdeliver/serv_listdeliver.c diff --git a/citadel/modules/listdeliver/serv_listdeliver.c b/citadel/modules/listdeliver/serv_listdeliver.c new file mode 100644 index 000000000..2fe3bcec5 --- /dev/null +++ b/citadel/modules/listdeliver/serv_listdeliver.c @@ -0,0 +1,95 @@ +/* + * This module delivers messages to mailing lists. + * + * Copyright (c) 2002-2021 by the citadel.org team + * + * This program is open source software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include "sysdep.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "citadel.h" +#include "server.h" +#include "citserver.h" +#include "support.h" +#include "config.h" +#include "user_ops.h" +#include "database.h" +#include "msgbase.h" +#include "internet_addressing.h" +#include "clientsocket.h" +#include "ctdl_module.h" + +int doing_listdeliver = 0; + + + +void listdeliver_sweep_room(struct ctdlroom *qrbuf, void *data) { +} + + + +void listdeliver_sweep(void) { + static time_t last_run = 0L; + + /* + * Run mailing list delivery no more frequently than once every 15 minutes (we should make this configurable) + */ + if ( (time(NULL) - last_run) < 900 ) { + return; + } + + /* + * This is a simple concurrency check to make sure only one listdeliver + * run is done at a time. We could do this with a mutex, but since we + * don't really require extremely fine granularity here, we'll do it + * with a static variable instead. + */ + if (doing_listdeliver) return; + doing_listdeliver = 1; + + /* + * Go through each room looking for mailing lists to process + */ + syslog(LOG_DEBUG, "listdeliver: sweep started"); + CtdlForEachRoom(listdeliver_sweep_room, NULL); + syslog(LOG_DEBUG, "listdeliver: ended"); + last_run = time(NULL); + doing_listdeliver = 0; +} + + + +/* + * Module entry point + */ +CTDL_MODULE_INIT(listdeliver) +{ + if (!threading) + { + CtdlRegisterSessionHook(listdeliver_sweep, EVT_TIMER, PRIO_AGGR + 50); + } + + /* return our module name for the log */ + return "listsub"; +} -- 2.30.2