]> code.citadel.org Git - citadel.git/commitdiff
* Suppress posting of messages to Aide> when the loopzapper catches dupes.
authorArt Cancro <ajc@citadel.org>
Fri, 6 Feb 2004 04:40:50 +0000 (04:40 +0000)
committerArt Cancro <ajc@citadel.org>
Fri, 6 Feb 2004 04:40:50 +0000 (04:40 +0000)
* New command NSYN to sync the entire contents of a room to a specified
  network node.  This will be used to bring new nodes in sync with existing
  nodes.

citadel/ChangeLog
citadel/serv_network.c
citadel/techdoc/session.txt

index fdd1ecd38963a9c00506449241915c4f5d9d8cd3..101a283820d8fe86d1e80b6e44cca22e8de54af1 100644 (file)
@@ -1,4 +1,10 @@
  $Log$
+ Revision 614.19  2004/02/06 04:40:50  ajc
+ * Suppress posting of messages to Aide> when the loopzapper catches dupes.
+ * New command NSYN to sync the entire contents of a room to a specified
+   network node.  This will be used to bring new nodes in sync with existing
+   nodes.
+
  Revision 614.18  2004/02/06 03:58:10  ajc
  * Added some comments to the sample citadel-slapd.conf
 
@@ -5277,4 +5283,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
-
index 2365e4a150cb4be7debcbe945a5e53f7cf286c5e..2778f76cf6ceff67b50a684b64dade4c29d29620 100644 (file)
@@ -842,6 +842,53 @@ void network_spoolout_room(char *room_to_spool) {
 }
 
 
+
+/*
+ * Send the *entire* contents of the current room to one specific network node,
+ * ignoring anything we know about which messages have already undergone
+ * network processing.  This can be used to bring a new node into sync.
+ */
+int network_sync_to(char *target_node) {
+       struct SpoolControl sc;
+       int num_spooled = 0;
+
+       /* Concise syntax because we don't need a full linked-list */
+       sc.ignet_push_shares = (struct namelist *)
+               mallok(sizeof(struct namelist));
+       sc.ignet_push_shares->next = NULL;
+       safestrncpy(sc.ignet_push_shares->name,
+               target_node,
+               sizeof sc.ignet_push_shares->name);
+
+       /* Send ALL messages */
+       num_spooled = CtdlForEachMessage(MSGS_ALL, 0L, NULL, NULL,
+               network_spool_msg, &sc);
+
+       /* Concise cleanup because we know there's only one node in the sc */
+       phree(sc.ignet_push_shares);
+
+       lprintf(7, "Synchronized %d messages to <%s>\n",
+               num_spooled, target_node);
+       return(num_spooled);
+}
+
+
+/*
+ * Implements the NSYN command
+ */
+void cmd_nsyn(char *argbuf) {
+       int num_spooled;
+       char target_node[SIZ];
+
+       if (CtdlAccessCheck(ac_aide)) return;
+
+       extract(target_node, argbuf, 0);
+       num_spooled = network_sync_to(target_node);
+       cprintf("%d Spooled %d messages.\n", CIT_OK, num_spooled);
+}
+
+
+
 /*
  * Batch up and send all outbound traffic from the current room
  */
@@ -1005,7 +1052,6 @@ void network_process_buffer(char *buffer, long size) {
        char *oldpath = NULL;
        char filename[SIZ];
        FILE *fp;
-       char buf[SIZ];
        char nexthop[SIZ];
 
        /* Set default target room to trash */
@@ -1080,20 +1126,12 @@ void network_process_buffer(char *buffer, long size) {
        }
 
        /*
-        * Check to see if we already have a copy of this message
+        * Check to see if we already have a copy of this message, and
+        * abort its processing if so.  (We used to post a warning to Aide>
+        * every time this happened, but the network is now so densely
+        * connected that it's inevitable.)
         */
        if (network_usetable(msg) != 0) {
-               snprintf(buf, sizeof buf,
-                       "Loopzapper rejected message <%s> "
-                       "from <%s> in <%s> @ <%s>\n",
-                       ((msg->cm_fields['I']!=NULL)?(msg->cm_fields['I']):""),
-                       ((msg->cm_fields['A']!=NULL)?(msg->cm_fields['A']):""),
-                       ((msg->cm_fields['O']!=NULL)?(msg->cm_fields['O']):""),
-                       ((msg->cm_fields['N']!=NULL)?(msg->cm_fields['N']):"")
-               );
-               aide_message(buf);
-               CtdlFreeMessage(msg);
-               msg = NULL;
                return;
        }
 
@@ -1604,6 +1642,7 @@ char *serv_network_init(void)
        CtdlRegisterProtoHook(cmd_gnet, "GNET", "Get network config");
        CtdlRegisterProtoHook(cmd_snet, "SNET", "Set network config");
        CtdlRegisterProtoHook(cmd_netp, "NETP", "Identify as network poller");
+       CtdlRegisterProtoHook(cmd_nsyn, "NSYN", "Synchronize room to node");
        CtdlRegisterSessionHook(network_do_queue, EVT_TIMER);
        return "$Id$";
 }
index 10a4b95195295ca9cdbca3d560f685d130e90e2a..eb95a92f205a0086973a935cf48db7a42e8dea09 100644 (file)
@@ -1,5 +1,5 @@
                   SESSION LAYER PROTOCOL FOR CITADEL/UX
-         (c) 1995-2003 by Art Cancro et. al.    All Rights Reserved
+         (c) 1995-2004 by Art Cancro et. al.    All Rights Reserved
 
 
  INTRODUCTION
@@ -1261,7 +1261,22 @@ two arguments: the node name of the calling system, and the "shared secret"
 password for that connection.  If the authentication succeeds, NETP will
 return OK, otherwise, it returns ERROR.
 
-
+ NSYN   (Network SYNchronize room)
+ This command can be used to synchronize the contents of a room on the
+network.  It is only usable by Aides.  It accepts one argument: the name of
+a network node (which must be a valid one).
+ When NSYN is run, the *entire* contents of the current room will be spooled
+to the specified node, without regard to whether any of the messages have
+already undergone network processing.  It is up to the receiving node to
+check for duplicates (the Citadel networker does handle this) and avoid
+posting them twice.
+ The command returns OK upon success or ERROR if the user is not an Aide.
+  
  NUOP   (Network Upload OPen file)
 
  Open a network spool file for uploading.  The client must have already