From: Kevin L. Mitchell Date: Mon, 16 Apr 2001 20:41:33 +0000 (+0000) Subject: Author: Kev X-Git-Url: http://git.pk910.de/?a=commitdiff_plain;h=9653d11e1df733afa5642933892859bc117b1d00;p=ircu2.10.12-pk.git Author: Kev Log message: Based on discussion with Bleep, and the change in /wallops implementation that has taken place on u2.10.10.pl14, sendcmdto_flag_butone() has been recast to broadcast them to all servers, regardless of what sorts of users those servers have on/behind them. This reduces CPU wasted on /wallops to the minimum practical, with only a small increase in protocol overhead--in my opinion, that overhead is not enough to worry about. git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@415 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- diff --git a/ChangeLog b/ChangeLog index a8a5ab0..82aeb8c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2001-04-16 Kevin L. Mitchell + * ircd/send.c (sendcmdto_flag_butone): recast to just broadcast to + all servers, rather than to only servers that have +w/+g/whatever + users on them; among other things, this removes that atrocity + known as sentalong[] from this function + * ircd/m_admin.c: must include ircd.h to declare "me"; must include hash.h to declare FindUser() diff --git a/ircd/send.c b/ircd/send.c index 2c9fb7b..04401f3 100644 --- a/ircd/send.c +++ b/ircd/send.c @@ -456,25 +456,16 @@ void sendcmdto_channel_butone(struct Client *from, const char *cmd, * Send a (prefixed) command to all users except that have * set. */ -/* XXX sentalong_marker used XXX - * - * Again, we can solve this use of sentalong_marker by adding a field - * to connections--a count of the number of +w users, and another count - * of +g users. Then, just walk through the local clients to send - * those messages, and another walk through the connected servers list, - * sending only if there's a non-zero count. No caveats here, either, - * beyond remembering to decrement the count when a user /quit's or is - * killed, or a server is squit. -Kev - */ void sendcmdto_flag_butone(struct Client *from, const char *cmd, const char *tok, struct Client *one, unsigned int flag, const char *pattern, ...) { struct VarData vd; struct Client *cptr; - struct MsgBuf *user_mb; - struct MsgBuf *serv_mb; + struct MsgBuf *mb; + struct DLink *lp; unsigned int oper_fl = 0; + int i; if (flag & FLAGS_OPER) { flag &= ~FLAGS_OPER; @@ -485,32 +476,32 @@ void sendcmdto_flag_butone(struct Client *from, const char *cmd, /* Build buffer to send to users */ va_start(vd.vd_args, pattern); - user_mb = msgq_make(0, "%:#C " MSG_WALLOPS " %v", from, &vd); + mb = msgq_make(0, "%:#C " MSG_WALLOPS " %v", from, &vd); va_end(vd.vd_args); + /* send buffer along! */ + for (i = 0; i <= HighestFd; i++) { + if (!(cptr = LocalClientArray[i]) || !(cli_flags(cptr) & flag) || + (oper_fl && !IsAnOper(cptr)) || cli_fd(cli_from(cptr)) < 0) + continue; /* skip it */ + send_buffer(cptr, mb, 1); + } + + msgq_clean(mb); + /* Build buffer to send to servers */ va_start(vd.vd_args, pattern); - serv_mb = msgq_make(&me, "%C %s %v", from, tok, &vd); + mb = msgq_make(&me, "%C %s %v", from, tok, &vd); va_end(vd.vd_args); /* send buffer along! */ - sentalong_marker++; - for (cptr = GlobalClientList; cptr; cptr = cli_next(cptr)) { - if (cli_from(cptr) == one || IsServer(cptr) || !(cli_flags(cptr) & flag) || - (MyConnect(cptr) && oper_fl && !IsAnOper(cptr)) || - cli_fd(cli_from(cptr)) < 0 || - sentalong[cli_fd(cli_from(cptr))] == sentalong_marker) - continue; /* skip it */ - sentalong[cli_fd(cli_from(cptr))] = sentalong_marker; - - if (MyConnect(cptr)) /* send right buffer */ - send_buffer(cptr, user_mb, 1); - else - send_buffer(cptr, serv_mb, 1); + for (lp = cli_serv(&me)->down; lp; lp = lp->next) { + if (one && lp->value.cptr == cli_from(one)) + continue; + send_buffer(lp->value.cptr, mb, 0); } - msgq_clean(user_mb); - msgq_clean(serv_mb); + msgq_clean(mb); } /*