Author: Kev <klmitch@mit.edu>
authorKevin L. Mitchell <klmitch@mit.edu>
Sun, 10 Jun 2001 12:38:56 +0000 (12:38 +0000)
committerKevin L. Mitchell <klmitch@mit.edu>
Sun, 10 Jun 2001 12:38:56 +0000 (12:38 +0000)
Log message:

Changes necessary to make SETTIME always be in the priority queue.

git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@496 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
include/s_user.h
include/send.h
ircd/m_server.c
ircd/m_settime.c
ircd/s_user.c
ircd/send.c

index 70ca85244e1f25c61aceba5d755f23035a7279fc..0f6d2464cb49cdf3b569b64362dd5186f63e932b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,24 @@
 2001-06-10  Kevin L. Mitchell  <klmitch@mit.edu>
 
+       * ircd/send.c: remove unused vsendcmdto_one(), consolidating it
+       into sendcmdto_one(); define new sendcmdto_prio_one(), which
+       places the message into the priority queue
+
+       * ircd/s_user.c (hunt_server_prio_cmd): definition of
+       hunt_server_prio_cmd(), which simply calls sendcmdto_prio_one()
+       instead of sendcmdto_one()
+
+       * ircd/m_settime.c: use sendcmdto_prio_one() and
+       hunt_server_prio_cmd() to send SETTIME
+
+       * ircd/m_server.c: use sendcmdto_prio_one() to send SETTIME
+
+       * include/send.h: removed declaration for unused vsendcmdto_one();
+       added a declaration for sendcmdto_prio_one()
+
+       * include/s_user.h: declare hunt_server_prio_cmd(), which calls
+       sendcmdto_prio_one()
+
        * ircd/send.c (sendcmdto_flag_butone): oops; /wallops should be
        put in the server's priority queue, too...
 
index 296d8193206cfd2785afa5189368065b5632ed0f..7de772aca951f372be0bcdcc8869c69a0027335c 100644 (file)
@@ -81,6 +81,10 @@ extern int hunt_server_cmd(struct Client *from, const char *cmd,
                           const char *tok, struct Client *one,
                           int MustBeOper, const char *pattern, int server,
                           int parc, char *parv[]);
+extern int hunt_server_prio_cmd(struct Client *from, const char *cmd,
+                               const char *tok, struct Client *one,
+                               int MustBeOper, const char *pattern,
+                               int server, int parc, char *parv[]);
 extern struct Client* next_client(struct Client* next, const char* ch);
 extern char *umode_str(struct Client *cptr);
 extern void send_umode(struct Client *cptr, struct Client *sptr, int old, int sendmask);
index ca83b50da9e0b68a37571b376e3c3e59c99cc104..8e62ca34fff2988192a502a7391cc3313c717140 100644 (file)
@@ -33,11 +33,10 @@ extern void sendcmdto_one(struct Client *from, const char *cmd,
                          const char *tok, struct Client *to,
                          const char *pattern, ...);
 
-
-/* Same as above, except it takes a va_list */
-extern void vsendcmdto_one(struct Client *from, const char *cmd,
-                          const char *tok, struct Client *to,
-                          const char *pattern, va_list vl);
+/* Same as above, except it puts the message on the priority queue */
+extern void sendcmdto_prio_one(struct Client *from, const char *cmd,
+                              const char *tok, struct Client *to,
+                              const char *pattern, ...);
 
 /* Send command to all servers except one */
 extern void sendcmdto_serv_butone(struct Client *from, const char *cmd,
index 0ddd244c5da95b8ea3caf072600d80cd601dec2e..56ce072ce5c85b06ce6b032595c3b40a63c97d5c 100644 (file)
@@ -759,7 +759,8 @@ int mr_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
                         "timestamp-clock difference of %Td seconds! "
                         "Used SETTIME to correct this.",
                         timestamp - recv_time);
-    sendcmdto_one(&me, CMD_SETTIME, cptr, "%Tu :%s", TStime(), cli_name(&me));
+    sendcmdto_prio_one(&me, CMD_SETTIME, cptr, "%Tu :%s", TStime(),
+                      cli_name(&me));
   }
 
   return ret;
@@ -1391,7 +1392,8 @@ int ms_server(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
     sendto_opmask_butone(0, SNO_OLDSNO, "Connected to a net with a "
                         "timestamp-clock difference of %Td seconds! Used "
                         "SETTIME to correct this.", timestamp - recv_time);
-    sendcmdto_one(&me, CMD_SETTIME, cptr, "%Tu :%s", TStime(), cli_name(&me));
+    sendcmdto_prio_one(&me, CMD_SETTIME, cptr, "%Tu :%s", TStime(),
+                      cli_name(&me));
   }
 
   return ret;
index 0847261f05131fd7dc51e9bcc30494a2e9d8a575..e1cfa050ac39aa339d6e40d78b67b08c60fc9308 100644 (file)
@@ -154,8 +154,8 @@ int ms_settime(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
   {
     ircd_snprintf(0, tbuf, sizeof(tbuf), "%Tu", TStime());
     parv[1] = tbuf;
-    if (hunt_server_cmd(sptr, CMD_SETTIME, cptr, 1, "%s %C", 2, parc, parv) !=
-        HUNTED_ISME)
+    if (hunt_server_prio_cmd(sptr, CMD_SETTIME, cptr, 1, "%s %C", 2, parc,
+                            parv) != HUNTED_ISME)
       return 0;
   }
 
@@ -224,14 +224,14 @@ int mo_settime(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
 
     for (lp = cli_serv(&me)->down; lp; lp = lp->next)
       if (cptr != lp->value.cptr && MsgQLength(&(cli_sendQ(lp->value.cptr))) < 8000)
-       sendcmdto_one(sptr, CMD_SETTIME, lp->value.cptr, "%s", parv[1]);
+       sendcmdto_prio_one(sptr, CMD_SETTIME, lp->value.cptr, "%s", parv[1]);
   }
   else
   {
     ircd_snprintf(0, tbuf, sizeof(tbuf), "%Tu", TStime());
     parv[1] = tbuf;
-    if (hunt_server_cmd(sptr, CMD_SETTIME, cptr, 1, "%s %C", 2, parc, parv) !=
-        HUNTED_ISME)
+    if (hunt_server_prio_cmd(sptr, CMD_SETTIME, cptr, 1, "%s %C", 2, parc,
+                            parv) != HUNTED_ISME)
       return 0;
   }
 
index 78d94cf08c7c6cb5d78a52b144c0bc89d5533f61..3887a998589c95830fb8be54a87875f5315388fc 100644 (file)
@@ -229,6 +229,52 @@ int hunt_server_cmd(struct Client *from, const char *cmd, const char *tok,
   return (HUNTED_PASS);
 }
 
+int hunt_server_prio_cmd(struct Client *from, const char *cmd, const char *tok,
+                        struct Client *one, int MustBeOper,
+                        const char *pattern, int server, int parc,
+                        char *parv[])
+{
+  struct Client *acptr;
+  char *to;
+
+  /* Assume it's me, if no server or an unregistered client */
+  if (parc <= server || EmptyString((to = parv[server])) || IsUnknown(from))
+    return (HUNTED_ISME);
+
+  /* Make sure it's a server */
+  if (MyUser(from)) {
+    /* Make sure it's a server */
+    if (!strchr(to, '*')) {
+      if (0 == (acptr = FindClient(to)))
+        return HUNTED_NOSUCH;
+
+      if (cli_user(acptr))
+        acptr = cli_user(acptr)->server;
+    } else if (!(acptr = find_match_server(to))) {
+      send_reply(from, ERR_NOSUCHSERVER, to);
+      return (HUNTED_NOSUCH);
+    }
+  } else if (!(acptr = FindNServer(to)))
+    return (HUNTED_NOSUCH);        /* Server broke off in the meantime */
+
+  if (IsMe(acptr))
+    return (HUNTED_ISME);
+
+  if (MustBeOper && !IsPrivileged(from)) {
+    send_reply(from, ERR_NOPRIVILEGES);
+    return HUNTED_NOSUCH;
+  }
+
+  assert(!IsServer(from));
+
+  parv[server] = (char *) acptr; /* HACK! HACK! HACK! ARGH! */
+
+  sendcmdto_prio_one(from, cmd, tok, acptr, pattern, parv[1], parv[2], parv[3],
+                    parv[4], parv[5], parv[6], parv[7], parv[8]);
+
+  return (HUNTED_PASS);
+}
+
 /*
  * 'do_nick_name' ensures that the given parameter (nick) is really a proper
  * string for a nickname (note, the 'nick' may be modified in the process...)
index cce22b13f1a5a3ed13f0ba64e9d7c6b15a165942..3c60223d4903ab1f1ebc5a6514b515f3d8f39b4a 100644 (file)
@@ -253,15 +253,31 @@ void sendrawto_one(struct Client *to, const char *pattern, ...)
 void sendcmdto_one(struct Client *from, const char *cmd, const char *tok,
                   struct Client *to, const char *pattern, ...)
 {
-  va_list vl;
+  struct VarData vd;
+  struct MsgBuf *mb;
 
-  va_start(vl, pattern);
-  vsendcmdto_one(from, cmd, tok, to, pattern, vl);
-  va_end(vl);
+  to = cli_from(to);
+
+  vd.vd_format = pattern; /* set up the struct VarData for %v */
+  va_start(vd.vd_args, pattern);
+
+  mb = msgq_make(to, "%:#C %s %v", from, IsServer(to) || IsMe(to) ? tok : cmd,
+                &vd);
+
+  va_end(vd.vd_args);
+
+  send_buffer(to, mb, 0);
+
+  msgq_clean(mb);
 }
 
-void vsendcmdto_one(struct Client *from, const char *cmd, const char *tok,
-                   struct Client *to, const char *pattern, va_list vl)
+/*
+ * Send a (prefixed) command to a single client in the priority queue;
+ * select  which of <cmd> <tok> to use depending on if to is a server
+ *or not.  <from> is the originator of the command.
+ */
+void sendcmdto_prio_one(struct Client *from, const char *cmd, const char *tok,
+                       struct Client *to, const char *pattern, ...)
 {
   struct VarData vd;
   struct MsgBuf *mb;
@@ -269,12 +285,14 @@ void vsendcmdto_one(struct Client *from, const char *cmd, const char *tok,
   to = cli_from(to);
 
   vd.vd_format = pattern; /* set up the struct VarData for %v */
-  vd.vd_args = vl;
+  va_start(vd.vd_args, pattern);
 
   mb = msgq_make(to, "%:#C %s %v", from, IsServer(to) || IsMe(to) ? tok : cmd,
                 &vd);
 
-  send_buffer(to, mb, 0);
+  va_end(vd.vd_args);
+
+  send_buffer(to, mb, 1);
 
   msgq_clean(mb);
 }