#include "euidindex.h"
#include "journaling.h"
#include "citadel_dirs.h"
+#include "serv_network.h"
long config_msgnum;
struct addresses_to_be_filed *atbf = NULL;
lprintf(CTDL_DEBUG, "CtdlSaveMsgPointerInRoom() skips repl checks\n");
}
+ /* Submit this room for net processing */
+ network_queue_room(&CC->room, NULL);
+
/* Go back to the room we were in before we wandered here... */
getroom(&CC->room, hold_rm);
/*
* When we do network processing, it's accomplished in two passes; one to
* gather a list of rooms and one to actually do them. It's ok that rplist
- * is global; this process *only* runs as part of the housekeeping loop and
- * therefore only one will run at a time.
+ * is global; we have a mutex that keeps it safe.
*/
struct RoomProcList *rplist = NULL;
int skipthisline = 0;
int i;
+ /*
+ * If the room doesn't exist, don't try to perform its networking tasks.
+ * Normally this should never happen, but once in a while maybe a room gets
+ * queued for networking and then deleted before it can happen.
+ */
if (getroom(&CC->room, room_to_spool) != 0) {
lprintf(CTDL_CRIT, "ERROR: cannot load <%s>\n", room_to_spool);
return;
begin_critical_section(S_NETCONFIGS);
+ /* Only do net processing for rooms that have netconfigs */
fp = fopen(filename, "r");
if (fp == NULL) {
end_critical_section(S_NETCONFIGS);
if (ptr == NULL) return;
safestrncpy(ptr->name, qrbuf->QRname, sizeof ptr->name);
+ begin_critical_section(S_RPLIST);
ptr->next = rplist;
rplist = ptr;
+ end_critical_section(S_RPLIST);
}
if (full_processing) {
lprintf(CTDL_DEBUG, "network: loading outbound queue\n");
ForEachRoom(network_queue_room, NULL);
+ }
+ if (rplist != NULL) {
lprintf(CTDL_DEBUG, "network: running outbound queue\n");
while (rplist != NULL) {
- network_spoolout_room(rplist->name);
+ char spoolroomname[ROOMNAMELEN];
+ safestrncpy(spoolroomname, rplist->name, sizeof spoolroomname);
+ begin_critical_section(S_RPLIST);
+
+ /* pop this record off the list */
ptr = rplist;
rplist = rplist->next;
free(ptr);
+
+ /* invalidate any duplicate entries to prevent double processing */
+ for (ptr=rplist; ptr!=NULL; ptr=ptr->next) {
+ if (!strcasecmp(ptr->name, spoolroomname)) {
+ ptr->name[0] = 0;
+ }
+ }
+
+ end_critical_section(S_RPLIST);
+ if (spoolroomname[0] != 0) {
+ network_spoolout_room(spoolroomname);
+ }
}
}