2 * This module delivers messages to mailing lists.
4 * Copyright (c) 2002-2021 by the citadel.org team
6 * This program is open source software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 3.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
24 #include <sys/types.h>
30 #include <libcitadel.h>
33 #include "citserver.h"
39 #include "internet_addressing.h"
40 #include "clientsocket.h"
41 #include "ctdl_module.h"
43 int doing_listdeliver = 0;
47 void listdeliver_sweep_room(struct ctdlroom *qrbuf, void *data) {
52 void listdeliver_sweep(void) {
53 static time_t last_run = 0L;
56 * Run mailing list delivery no more frequently than once every 15 minutes (we should make this configurable)
58 if ( (time(NULL) - last_run) < 900 ) {
63 * This is a simple concurrency check to make sure only one listdeliver
64 * run is done at a time. We could do this with a mutex, but since we
65 * don't really require extremely fine granularity here, we'll do it
66 * with a static variable instead.
68 if (doing_listdeliver) return;
69 doing_listdeliver = 1;
72 * Go through each room looking for mailing lists to process
74 syslog(LOG_DEBUG, "listdeliver: sweep started");
75 CtdlForEachRoom(listdeliver_sweep_room, NULL);
76 syslog(LOG_DEBUG, "listdeliver: ended");
77 last_run = time(NULL);
78 doing_listdeliver = 0;
86 CTDL_MODULE_INIT(listdeliver)
90 CtdlRegisterSessionHook(listdeliver_sweep, EVT_TIMER, PRIO_AGGR + 50);
93 /* return our module name for the log */