]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_network.c
* Killed off CtdlGetDynamicSymbol() and just put all the symbols in server.h
[citadel.git] / citadel / serv_network.c
index cd906ca87c36daf37d2f67a7292044c6e19619e4..3088de2debfa478e8d89535cecee6fbe18c50753 100644 (file)
  *
  */
 
-/*
- * FIXME
- * Don't allow polls during network processing
- */
-
 /*
  * Duration of time (in seconds) after which pending list subscribe/unsubscribe
  * requests that have not been confirmed will be deleted.
@@ -58,7 +53,7 @@
 #include "citserver.h"
 #include "support.h"
 #include "config.h"
-#include "dynloader.h"
+#include "serv_extensions.h"
 #include "room_ops.h"
 #include "user_ops.h"
 #include "policy.h"
@@ -74,6 +69,8 @@
 #include "snprintf.h"
 #endif
 
+/* Nonzero while we are doing outbound network processing */
+static int doing_queue = 0;
 
 /*
  * When we do network processing, it's accomplished in two passes; one to
@@ -337,10 +334,10 @@ void cmd_gnet(char *argbuf) {
        FILE *fp;
 
        if (CtdlAccessCheck(ac_room_aide)) return;
-       assoc_file_name(filename, sizeof filename, &CC->quickroom, "netconfigs");
+       assoc_file_name(filename, sizeof filename, &CC->room, "netconfigs");
        cprintf("%d Network settings for room #%ld <%s>\n",
                LISTING_FOLLOWS,
-               CC->quickroom.QRnumber, CC->quickroom.QRname);
+               CC->room.QRnumber, CC->room.QRname);
 
        fp = fopen(filename, "r");
        if (fp != NULL) {
@@ -363,7 +360,7 @@ void cmd_snet(char *argbuf) {
 
        if (CtdlAccessCheck(ac_room_aide)) return;
        safestrncpy(tempfilename, tmpnam(NULL), sizeof tempfilename);
-       assoc_file_name(filename, sizeof filename, &CC->quickroom, "netconfigs");
+       assoc_file_name(filename, sizeof filename, &CC->room, "netconfigs");
 
        fp = fopen(tempfilename, "w");
        if (fp == NULL) {
@@ -511,7 +508,7 @@ void network_spool_msg(long msgnum, void *userdata) {
                        if (msg->cm_fields['C'] != NULL) {
                                phree(msg->cm_fields['C']);
                        }
-                       msg->cm_fields['C'] = strdoop(CC->quickroom.QRname);
+                       msg->cm_fields['C'] = strdoop(CC->room.QRname);
 
                        /*
                         * Determine if this message is set to be deleted
@@ -576,7 +573,7 @@ void network_spool_msg(long msgnum, void *userdata) {
 
        /* Delete this message if delete-after-send is set */
        if (delete_after_send) {
-               CtdlDeleteMessages(CC->quickroom.QRname, msgnum, "");
+               CtdlDeleteMessages(CC->room.QRname, msgnum, "");
        }
 
 }
@@ -610,9 +607,9 @@ void network_deliver_digest(struct SpoolControl *sc) {
 
        sprintf(buf, "%ld", time(NULL));
        msg->cm_fields['T'] = strdoop(buf);
-       msg->cm_fields['A'] = strdoop(CC->quickroom.QRname);
-       msg->cm_fields['U'] = strdoop(CC->quickroom.QRname);
-       sprintf(buf, "room_%s@%s", CC->quickroom.QRname, config.c_fqdn);
+       msg->cm_fields['A'] = strdoop(CC->room.QRname);
+       msg->cm_fields['U'] = strdoop(CC->room.QRname);
+       sprintf(buf, "room_%s@%s", CC->room.QRname, config.c_fqdn);
        for (i=0; i<strlen(buf); ++i) {
                if (isspace(buf[i])) buf[i]='_';
                buf[i] = tolower(buf[i]);
@@ -696,28 +693,24 @@ void network_spoolout_room(char *room_to_spool) {
        int skipthisline = 0;
        int i;
 
-       lprintf(7, "Spooling <%s>\n", room_to_spool);
-       if (getroom(&CC->quickroom, room_to_spool) != 0) {
+       if (getroom(&CC->room, room_to_spool) != 0) {
                lprintf(1, "ERROR: cannot load <%s>\n", room_to_spool);
                return;
        }
 
        memset(&sc, 0, sizeof(struct SpoolControl));
-       assoc_file_name(filename, sizeof filename, &CC->quickroom, "netconfigs");
+       assoc_file_name(filename, sizeof filename, &CC->room, "netconfigs");
 
        begin_critical_section(S_NETCONFIGS);
        end_critical_section(S_NETCONFIGS);
 
        fp = fopen(filename, "r");
        if (fp == NULL) {
-               lprintf(7, "Outbound batch processing skipped for <%s>\n",
-                       CC->quickroom.QRname);
                end_critical_section(S_NETCONFIGS);
                return;
        }
 
-       lprintf(5, "Outbound batch processing started for <%s>\n",
-               CC->quickroom.QRname);
+       lprintf(5, "Networking started for <%s>\n", CC->room.QRname);
 
        while (fgets(buf, sizeof buf, fp) != NULL) {
                buf[strlen(buf)-1] = 0;
@@ -789,7 +782,7 @@ void network_spoolout_room(char *room_to_spool) {
 
        /* If we wrote a digest, deliver it and then close it */
        snprintf(buf, sizeof buf, "room_%s@%s",
-               CC->quickroom.QRname, config.c_fqdn);
+               CC->room.QRname, config.c_fqdn);
        for (i=0; i<strlen(buf); ++i) {
                buf[i] = tolower(buf[i]);
                if (isspace(buf[i])) buf[i] = '_';
@@ -801,7 +794,7 @@ void network_spoolout_room(char *room_to_spool) {
                                        "You are subscribed to the '%s' "
                                        "list.\n"
                                        "To post to the list: %s\n",
-                                       CC->quickroom.QRname, buf
+                                       CC->room.QRname, buf
                );
                network_deliver_digest(&sc);    /* deliver and close */
        }
@@ -846,16 +839,13 @@ void network_spoolout_room(char *room_to_spool) {
                fclose(fp);
        }
        end_critical_section(S_NETCONFIGS);
-
-       lprintf(5, "Outbound batch processing finished for <%s>\n",
-               CC->quickroom.QRname);
 }
 
 
 /*
  * Batch up and send all outbound traffic from the current room
  */
-void network_queue_room(struct quickroom *qrbuf, void *data) {
+void network_queue_room(struct ctdlroom *qrbuf, void *data) {
        struct RoomProcList *ptr;
 
        ptr = (struct RoomProcList *) mallok(sizeof (struct RoomProcList));
@@ -1471,7 +1461,6 @@ void network_poll_other_citadel_nodes(void) {
  * Run through the rooms doing various types of network stuff.
  */
 void network_do_queue(void) {
-       static int doing_queue = 0;
        static time_t last_run = 0L;
        struct RoomProcList *ptr;
 
@@ -1542,6 +1531,11 @@ void cmd_netp(char *cmdbuf)
        char secret[SIZ];
        char nexthop[SIZ];
 
+       if (doing_queue) {
+               cprintf("%d spooling - try again in a few minutes\n", ERROR);
+               return;
+       }
+
        extract(node, cmdbuf, 0);
        extract(pass, cmdbuf, 1);