From: wiebe Date: Thu, 29 Jan 2009 19:03:57 +0000 (+0100) Subject: split.patch - tidy up comments, truncate servernames and reasons, fixed bug in split_... X-Git-Url: https://jfr.im/git/irc/quakenet/snircd-patchqueue.git/commitdiff_plain/4b4a62e94e015ca05285d925aebfae367021250e?ds=sidebyside split.patch - tidy up comments, truncate servernames and reasons, fixed bug in split_add not getting the correct flags, protect against servers with a bad nettime - lastmod greater than nettime+600 are corrected and ops are warned, removed unused flag SPLIT_CREATION --- diff --git a/split.patch b/split.patch index e00be63..da7f0d0 100644 --- a/split.patch +++ b/split.patch @@ -7,9 +7,9 @@ Add split.c split.h m_split.c NOTE: feature SPLIT is default enabled as that is just easier when working on this patch. -diff -r 5ec670983aff doc/api/log.txt ---- a/doc/api/log.txt Wed Jan 28 15:15:55 2009 +0100 -+++ b/doc/api/log.txt Wed Jan 28 15:46:43 2009 +0100 +diff -r 88fea3d419e4 doc/api/log.txt +--- a/doc/api/log.txt Thu Jan 29 14:02:57 2009 +0100 ++++ b/doc/api/log.txt Thu Jan 29 19:59:36 2009 +0100 @@ -41,7 +41,7 @@ @@ -19,9 +19,9 @@ diff -r 5ec670983aff doc/api/log.txt LS_OPERKILL, LS_SERVKILL, LS_USER, LS_OPER, LS_RESOLVER, LS_SOCKET, LS_DEBUG, LS_OLDLOG, LS_LAST_SYSTEM -diff -r 5ec670983aff include/handlers.h ---- a/include/handlers.h Wed Jan 28 15:15:55 2009 +0100 -+++ b/include/handlers.h Wed Jan 28 15:46:43 2009 +0100 +diff -r 88fea3d419e4 include/handlers.h +--- a/include/handlers.h Thu Jan 29 14:02:57 2009 +0100 ++++ b/include/handlers.h Thu Jan 29 19:59:36 2009 +0100 @@ -139,6 +139,7 @@ extern int m_registered(struct Client*, struct Client*, int, char*[]); extern int m_sethost(struct Client*, struct Client*, int, char*[]); @@ -46,9 +46,9 @@ diff -r 5ec670983aff include/handlers.h extern int ms_squit(struct Client*, struct Client*, int, char*[]); extern int ms_stats(struct Client*, struct Client*, int, char*[]); extern int ms_topic(struct Client*, struct Client*, int, char*[]); -diff -r 5ec670983aff include/ircd_features.h ---- a/include/ircd_features.h Wed Jan 28 15:15:55 2009 +0100 -+++ b/include/ircd_features.h Wed Jan 28 15:46:43 2009 +0100 +diff -r 88fea3d419e4 include/ircd_features.h +--- a/include/ircd_features.h Thu Jan 29 14:02:57 2009 +0100 ++++ b/include/ircd_features.h Thu Jan 29 19:59:36 2009 +0100 @@ -112,6 +112,10 @@ FEAT_SETHOST_USER, FEAT_SETHOST_AUTO, @@ -68,9 +68,9 @@ diff -r 5ec670983aff include/ircd_features.h FEAT_HIS_STATS_s, FEAT_HIS_STATS_t, FEAT_HIS_STATS_T, -diff -r 5ec670983aff include/ircd_log.h ---- a/include/ircd_log.h Wed Jan 28 15:15:55 2009 +0100 -+++ b/include/ircd_log.h Wed Jan 28 15:46:43 2009 +0100 +diff -r 88fea3d419e4 include/ircd_log.h +--- a/include/ircd_log.h Thu Jan 29 14:02:57 2009 +0100 ++++ b/include/ircd_log.h Thu Jan 29 19:59:36 2009 +0100 @@ -55,6 +55,7 @@ LS_OPERMODE, /**< Uses of OPMODE, CLEARMODE< etc. */ LS_GLINE, /**< Adding, (de-)activating or removing GLINEs. */ @@ -79,9 +79,9 @@ diff -r 5ec670983aff include/ircd_log.h LS_WHO, /**< Use of extended WHO privileges. */ LS_NETWORK, /**< New server connections. */ LS_OPERKILL, /**< Kills by IRC operators. */ -diff -r 5ec670983aff include/msg.h ---- a/include/msg.h Wed Jan 28 15:15:55 2009 +0100 -+++ b/include/msg.h Wed Jan 28 15:46:43 2009 +0100 +diff -r 88fea3d419e4 include/msg.h +--- a/include/msg.h Thu Jan 29 14:02:57 2009 +0100 ++++ b/include/msg.h Thu Jan 29 19:59:36 2009 +0100 @@ -336,6 +336,10 @@ #define TOK_JUPE "JU" #define CMD_JUPE MSG_JUPE, TOK_JUPE @@ -93,9 +93,9 @@ diff -r 5ec670983aff include/msg.h #define MSG_OPMODE "OPMODE" /* OPMO */ #define TOK_OPMODE "OM" #define CMD_OPMODE MSG_OPMODE, TOK_OPMODE -diff -r 5ec670983aff include/numeric.h ---- a/include/numeric.h Wed Jan 28 15:15:55 2009 +0100 -+++ b/include/numeric.h Wed Jan 28 15:46:43 2009 +0100 +diff -r 88fea3d419e4 include/numeric.h +--- a/include/numeric.h Thu Jan 29 14:02:57 2009 +0100 ++++ b/include/numeric.h Thu Jan 29 19:59:36 2009 +0100 @@ -118,6 +118,7 @@ #define RPL_STATSALINE 226 /* Hybrid, Undernet */ #define RPL_STATSWELCOME 227 /* QuakeNet extension */ @@ -121,10 +121,10 @@ diff -r 5ec670983aff include/numeric.h #define ERR_SILELISTFULL 511 /* Undernet extension */ /* ERR_NOTIFYFULL 512 aircd */ /* ERR_TOOMANYWATCH 512 Numeric List: Dalnet */ -diff -r 5ec670983aff include/split.h +diff -r 88fea3d419e4 include/split.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 -+++ b/include/split.h Wed Jan 28 15:46:43 2009 +0100 -@@ -0,0 +1,106 @@ ++++ b/include/split.h Thu Jan 29 19:59:36 2009 +0100 +@@ -0,0 +1,110 @@ +#ifndef INCLUDED_split_h +#define INCLUDED_split_h +/* @@ -149,7 +149,6 @@ diff -r 5ec670983aff include/split.h + */ +/** @file + * @brief Interface and declarations for split server handling. -+ * @version $Id: jupe.h 1208 2004-10-03 14:12:35Z entrope $ + */ +#ifndef INCLUDED_sys_types_h +#include @@ -160,7 +159,13 @@ diff -r 5ec670983aff include/split.h +struct Client; +struct StatDesc; + -+#define SPLIT_MAX_EXPIRE 2419200 /**< Maximum split expiration time (4 weeks). */ ++#define SPLIT_MAX_EXPIRE 2419200 /**< Maximum split expiration time (4 weeks). ++ * that an operator can use in /SPLIT ++ */ ++#define SPLIT_MAX_DRIFT 600 /**< Maximum drift in seconds allowed in lastmod ++ * timestamp ++ * when greater correct and throw warning ++ */ + +/* Describes a SPLIT server entry. */ +struct Split { @@ -193,11 +198,10 @@ diff -r 5ec670983aff include/split.h +#define SPLIT_EXPIRE 0x01 /**< Expiration time update. */ +#define SPLIT_LIFETIME 0x02 /**< Record lifetime update. */ +#define SPLIT_REASON 0x04 /**< Reason update. */ -+#define SPLIT_CREATION 0x08 /**< TODO: Creation time update - unused. */ -+#define SPLIT_MODIFY 0x10 /**< No state change. */ ++#define SPLIT_MODIFY 0x08 /**< No state change. */ + +/* mask for Split update flags. */ -+#define SPLIT_UPDATE (SPLIT_EXPIRE | SPLIT_CREATION | SPLIT_LIFETIME | SPLIT_REASON) ++#define SPLIT_UPDATE (SPLIT_EXPIRE | SPLIT_LIFETIME | SPLIT_REASON) + +/* test whether a split entry is active. */ +#define SplitIsActive(s) ((s)->sp_flags & SPLIT_ACTIVE) @@ -231,9 +235,9 @@ diff -r 5ec670983aff include/split.h +extern int split_memory_count(size_t *sp_size); + +#endif /* INCLUDED_split_h */ -diff -r 5ec670983aff ircd/Makefile.in ---- a/ircd/Makefile.in Wed Jan 28 15:15:55 2009 +0100 -+++ b/ircd/Makefile.in Wed Jan 28 15:46:43 2009 +0100 +diff -r 88fea3d419e4 ircd/Makefile.in +--- a/ircd/Makefile.in Thu Jan 29 14:02:57 2009 +0100 ++++ b/ircd/Makefile.in Thu Jan 29 19:59:36 2009 +0100 @@ -173,6 +173,7 @@ m_sethost.c \ m_settime.c \ @@ -291,9 +295,9 @@ diff -r 5ec670983aff ircd/Makefile.in uping.o: uping.c ../config.h ../include/uping.h ../include/ircd_defs.h \ ../include/ircd_events.h ../config.h ../include/res.h \ ../include/client.h ../include/dbuf.h ../include/msgq.h \ -diff -r 5ec670983aff ircd/ircd.c ---- a/ircd/ircd.c Wed Jan 28 15:15:55 2009 +0100 -+++ b/ircd/ircd.c Wed Jan 28 15:46:43 2009 +0100 +diff -r 88fea3d419e4 ircd/ircd.c +--- a/ircd/ircd.c Thu Jan 29 14:02:57 2009 +0100 ++++ b/ircd/ircd.c Thu Jan 29 19:59:36 2009 +0100 @@ -55,6 +55,7 @@ #include "s_misc.h" #include "s_stats.h" @@ -312,9 +316,9 @@ diff -r 5ec670983aff ircd/ircd.c event_loop(); return 0; -diff -r 5ec670983aff ircd/ircd_features.c ---- a/ircd/ircd_features.c Wed Jan 28 15:15:55 2009 +0100 -+++ b/ircd/ircd_features.c Wed Jan 28 15:46:43 2009 +0100 +diff -r 88fea3d419e4 ircd/ircd_features.c +--- a/ircd/ircd_features.c Thu Jan 29 14:02:57 2009 +0100 ++++ b/ircd/ircd_features.c Thu Jan 29 19:59:36 2009 +0100 @@ -366,6 +366,10 @@ F_B(SETHOST_USER, 0, 0, 0), F_B(SETHOST_AUTO, 0, 0, 0), @@ -334,9 +338,9 @@ diff -r 5ec670983aff ircd/ircd_features.c F_B(HIS_STATS_s, 0, 1, 0), F_B(HIS_STATS_t, 0, 1, 0), F_B(HIS_STATS_T, 0, 1, 0), -diff -r 5ec670983aff ircd/ircd_log.c ---- a/ircd/ircd_log.c Wed Jan 28 15:15:55 2009 +0100 -+++ b/ircd/ircd_log.c Wed Jan 28 15:46:43 2009 +0100 +diff -r 88fea3d419e4 ircd/ircd_log.c +--- a/ircd/ircd_log.c Thu Jan 29 14:02:57 2009 +0100 ++++ b/ircd/ircd_log.c Thu Jan 29 19:59:36 2009 +0100 @@ -154,6 +154,7 @@ S(OPERMODE, -1, SNO_HACK4), S(GLINE, -1, SNO_GLINE), @@ -345,9 +349,9 @@ diff -r 5ec670983aff ircd/ircd_log.c S(WHO, -1, 0), S(NETWORK, -1, SNO_NETWORK), S(OPERKILL, -1, 0), -diff -r 5ec670983aff ircd/m_endburst.c ---- a/ircd/m_endburst.c Wed Jan 28 15:15:55 2009 +0100 -+++ b/ircd/m_endburst.c Wed Jan 28 15:46:44 2009 +0100 +diff -r 88fea3d419e4 ircd/m_endburst.c +--- a/ircd/m_endburst.c Thu Jan 29 14:02:57 2009 +0100 ++++ b/ircd/m_endburst.c Thu Jan 29 19:59:36 2009 +0100 @@ -85,6 +85,7 @@ #include "client.h" #include "hash.h" @@ -383,9 +387,9 @@ diff -r 5ec670983aff ircd/m_endburst.c if (MyConnect(sptr)) sendcmdto_one(&me, CMD_END_OF_BURST_ACK, sptr, ""); -diff -r 5ec670983aff ircd/m_reburst.c ---- a/ircd/m_reburst.c Wed Jan 28 15:15:55 2009 +0100 -+++ b/ircd/m_reburst.c Wed Jan 28 15:46:44 2009 +0100 +diff -r 88fea3d419e4 ircd/m_reburst.c +--- a/ircd/m_reburst.c Thu Jan 29 14:02:57 2009 +0100 ++++ b/ircd/m_reburst.c Thu Jan 29 19:59:36 2009 +0100 @@ -102,6 +102,7 @@ #include "ircd_snprintf.h" #include "gline.h" @@ -405,9 +409,9 @@ diff -r 5ec670983aff ircd/m_reburst.c default: break; } -diff -r 5ec670983aff ircd/m_server.c ---- a/ircd/m_server.c Wed Jan 28 15:15:55 2009 +0100 -+++ b/ircd/m_server.c Wed Jan 28 15:46:44 2009 +0100 +diff -r 88fea3d419e4 ircd/m_server.c +--- a/ircd/m_server.c Thu Jan 29 14:02:57 2009 +0100 ++++ b/ircd/m_server.c Thu Jan 29 19:59:36 2009 +0100 @@ -47,6 +47,7 @@ #include "s_misc.h" #include "s_serv.h" @@ -426,10 +430,10 @@ diff -r 5ec670983aff ircd/m_server.c /* * Old sendto_serv_but_one() call removed because we now need to send * different names to different servers (domain name matching). -diff -r 5ec670983aff ircd/m_split.c +diff -r 88fea3d419e4 ircd/m_split.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 -+++ b/ircd/m_split.c Wed Jan 28 15:46:44 2009 +0100 -@@ -0,0 +1,378 @@ ++++ b/ircd/m_split.c Thu Jan 29 19:59:36 2009 +0100 +@@ -0,0 +1,392 @@ +/* + * IRC - Internet Relay Chat, ircd/m_split.c + * Copyright (C) 1990 Jarkko Oikarinen and @@ -453,7 +457,6 @@ diff -r 5ec670983aff ircd/m_split.c + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * -+ * $Id: m_split.c 1737 2006-12-19 05:20:48Z entrope $ + */ + +/* @@ -564,19 +567,21 @@ diff -r 5ec670983aff ircd/m_split.c + /* server param */ + server = parv[1]; + ++ /* check for ! prefix - force removing */ + if (*server == '!') { + server++; -+ action = SPLIT_REMOVE; /* removing entry */ ++ action = SPLIT_REMOVE; + } -+ -+ switch (*server) { /* handle + and - */ -+ case '+': /* activate the split entry */ ++ ++ /* check for + and - prefix */ ++ switch (*server) { ++ case '+': + if (action != SPLIT_REMOVE) + action = SPLIT_ACTIVATE; + server++; + break; + -+ case '-': /* deactivate the entry */ ++ case '-': + if (action != SPLIT_REMOVE) + action = SPLIT_DEACTIVATE; + server++; @@ -590,7 +595,7 @@ diff -r 5ec670983aff ircd/m_split.c + * it all together and convert the rest of the arguments. + */ + -+ /* can't modify a split entry that doesn't exist, so remap to activate */ ++ /* cannot modify a split entry that does not exist - remap to activate */ + if (!asplit && action == SPLIT_MODIFY) + action = SPLIT_ACTIVATE; + @@ -603,10 +608,14 @@ diff -r 5ec670983aff ircd/m_split.c + expire = atoi(parv[3]); + lastmod = atoi(parv[4]); + lifetime = atoi(parv[5]); ++ + /* got a reason too */ + if (parc > 5) + reason = parv[parc - 1]; ++ else ++ flags &= ~SPLIT_REASON; + ++ /* debug */ + Debug((DEBUG_DEBUG, "I have a SPLIT I am acting upon now; " + "server %s, action %s, creation %Tu, expire %Tu, " + "lastmod %Tu, lifetime %Tu, reason: %s; split %s!", server, @@ -616,9 +625,7 @@ diff -r 5ec670983aff ircd/m_split.c + creation, expire, lastmod, lifetime, reason, + asplit ? "EXISTS" : "does not exist")); + -+ /* OK, at this point, we have converted all available parameters. -+ * Let's actually do the action! -+ */ ++ /* modify or remove an existing SPLIT */ + if (asplit) { + if (action == SPLIT_REMOVE) + return split_remove(cptr, sptr, asplit, reason); @@ -628,19 +635,21 @@ diff -r 5ec670983aff ircd/m_split.c + + /* desynch or cross - we do not have it so we cannot remove it */ + /* TODO: manually propagate the message ? -+ * ..but if we do not have it, can our downlinks have it? -+ * they could if my oper force removed it earlier, and then my downlinks linked -+ * no, then they would have bursted it again to us.. argh ++ * ++ * but if we do not have it, can our downlinks have it? ++ * they could if my oper force removed it earlier, and then my downlinks linked ++ * no, then they would have bursted it again to us.. argh + */ + if (!asplit && action == SPLIT_REMOVE) + return 0; + ++ /* this should not happen */ + assert(action != SPLIT_MODIFY); + assert(action != SPLIT_REMOVE); + -+ /* only give one flag when needed - SPLIT_ACTIVE */ ++ /* create a new SPLIT */ + return split_add(cptr, sptr, server, reason, creation, expire, lastmod, lifetime, -+ (flags & SPLIT_ACTIVATE) ? SPLIT_ACTIVE : 0); ++ action == SPLIT_ACTIVATE ? SPLIT_ACTIVE : 0); +} + + @@ -665,7 +674,7 @@ diff -r 5ec670983aff ircd/m_split.c + unsigned int flags = 0; + enum SplitAction action = SPLIT_MODIFY; + time_t expire = 0, lastmod = TStime(), creation = TStime(); -+ char *server = parv[1], *end; ++ char *server, *end; + const char *reason = NULL; + + /* listing */ @@ -676,20 +685,24 @@ diff -r 5ec670983aff ircd/m_split.c + return split_list(sptr, 0); + } + -+ /* force removal */ ++ /* set server */ ++ server = parv[1]; ++ ++ /* ! prefix - force removal */ + if (*server == '!') { + server++; + action = SPLIT_REMOVE; + } + -+ switch (*server) { /* handle + and - */ -+ case '+': /* activate the split entry */ ++ /* handle + and - */ ++ switch (*server) { ++ case '+': + if (action != SPLIT_REMOVE) + action = SPLIT_ACTIVATE; + server++; + break; + -+ case '-': /* deactivate the split entry */ ++ case '-': + if (action != SPLIT_REMOVE) + action = SPLIT_DEACTIVATE; + server++; @@ -702,7 +715,7 @@ diff -r 5ec670983aff ircd/m_split.c + + /* if we have an expire, this must be it */ + if (parc > 2) -+ expire = strtol(parv[2], &end, 10); /* and the expiration */ ++ expire = strtol(parv[2], &end, 10); + + /* got reason and expire */ + if (parc > 3) { @@ -720,7 +733,8 @@ diff -r 5ec670983aff ircd/m_split.c + /* set reason */ + if (flags & SPLIT_REASON) { + reason = parv[parc - 1]; -+ if (reason[0] == '\0') /* reason is empty */ ++ /* ignore empty reason */ ++ if (EmptyString(reason)) + flags &= ~SPLIT_REASON; + } + @@ -740,19 +754,17 @@ diff -r 5ec670983aff ircd/m_split.c + expire += TStime(); + } + ++ /* TODO: but allow force removal when disabled? */ + /* check feature and privs */ -+ if (!feature_bool(FEAT_SPLIT)) /* TODO: but allow force removal? */ ++ if (!feature_bool(FEAT_SPLIT)) + return send_reply(sptr, ERR_DISABLED, "SPLIT"); -+ else if (!HasPriv(sptr, PRIV_SERVERINFO)) /* TODO: create PRIV_SPLIT - need help there */ ++ /* TODO: create PRIV_SPLIT - need help there */ ++ else if (!HasPriv(sptr, PRIV_SERVERINFO)) + return send_reply(sptr, ERR_NOPRIVILEGES); + -+ /* find the split */ ++ /* we have all we need - find the split */ + asplit = split_find(server); + -+ /* We now have all the pieces to tell us what we've got; let's put -+ * it all together and convert the rest of the arguments. -+ */ -+ + /* SPLIT not found and thus we cannot: + * remove SPLIT we do not have + * add new SPLIT without expire and reason @@ -764,10 +776,11 @@ diff -r 5ec670983aff ircd/m_split.c + (action == SPLIT_MODIFY && !reason))) + return send_reply(sptr, ERR_NOSUCHSPLIT, server); + -+ /* can't modify a split entry that doesn't exist, so remap to activate */ ++ /* cannot modify a split entry that does not exist - remap to activate */ + if (!asplit && action == SPLIT_MODIFY) + action = SPLIT_ACTIVATE; + ++ /* debug */ + Debug((DEBUG_DEBUG, "I have a SPLIT I am acting upon now; " + "server %s, action %s, expire %Tu, " + "reason: %s; split %s! (fields present: %s %s)", server, @@ -778,13 +791,15 @@ diff -r 5ec670983aff ircd/m_split.c + flags & SPLIT_EXPIRE ? "expire" : "", + flags & SPLIT_REASON ? "reason" : "")); + -+ if (asplit) { /* modifying an existing SPLIT */ ++ /* modify or remove an existing SPLIT */ ++ if (asplit) { + if (action == SPLIT_REMOVE) + return split_remove(cptr, sptr, asplit, reason); + return split_modify(cptr, sptr, asplit, action, reason, + asplit->sp_creation, expire, lastmod, asplit->sp_lifetime, flags); + } + ++ /* this should not happen */ + assert(action != SPLIT_MODIFY); + assert(action != SPLIT_REMOVE); + @@ -803,31 +818,34 @@ diff -r 5ec670983aff ircd/m_split.c + */ +int m_split(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) +{ ++ /* TODO: this is not used at all at the moment ++ * create a FEAT_HIS_SPLIT ? ++ */ + if (parc < 2) + return split_list(sptr, 0); + + return split_list(sptr, parv[1]); +} -diff -r 5ec670983aff ircd/parse.c ---- a/ircd/parse.c Wed Jan 28 15:15:55 2009 +0100 -+++ b/ircd/parse.c Wed Jan 28 15:46:44 2009 +0100 -@@ -505,6 +505,13 @@ - /* UNREG, CLIENT, SERVER, OPER, SERVICE, HELP */ +diff -r 88fea3d419e4 ircd/parse.c +--- a/ircd/parse.c Thu Jan 29 14:02:57 2009 +0100 ++++ b/ircd/parse.c Thu Jan 29 19:59:36 2009 +0100 +@@ -506,6 +506,13 @@ { m_unregistered, m_not_oper, ms_jupe, mo_jupe, m_ignore, mh_jupe } }, -+ { + { + MSG_SPLIT, + TOK_SPLIT, + 0, MAXPARA, MFLG_SLOW, 0, NULL, + /* UNREG, CLIENT, SERVER, OPER, SERVICE, HELP */ + { m_unregistered, m_not_oper, ms_split, mo_split, m_ignore, mh_nohelp } + }, - { ++ { MSG_OPMODE, TOK_OPMODE, -diff -r 5ec670983aff ircd/s_conf.c ---- a/ircd/s_conf.c Wed Jan 28 15:15:55 2009 +0100 -+++ b/ircd/s_conf.c Wed Jan 28 15:46:44 2009 +0100 + 0, MAXPARA, MFLG_SLOW, 0, NULL, +diff -r 88fea3d419e4 ircd/s_conf.c +--- a/ircd/s_conf.c Thu Jan 29 14:02:57 2009 +0100 ++++ b/ircd/s_conf.c Thu Jan 29 19:59:36 2009 +0100 @@ -53,6 +53,7 @@ #include "s_debug.h" #include "s_misc.h" @@ -844,9 +862,9 @@ diff -r 5ec670983aff ircd/s_conf.c return ret; } -diff -r 5ec670983aff ircd/s_debug.c ---- a/ircd/s_debug.c Wed Jan 28 15:15:55 2009 +0100 -+++ b/ircd/s_debug.c Wed Jan 28 15:46:44 2009 +0100 +diff -r 88fea3d419e4 ircd/s_debug.c +--- a/ircd/s_debug.c Thu Jan 29 14:02:57 2009 +0100 ++++ b/ircd/s_debug.c Thu Jan 29 19:59:36 2009 +0100 @@ -48,6 +48,7 @@ #include "s_user.h" #include "s_stats.h" @@ -884,9 +902,9 @@ diff -r 5ec670983aff ircd/s_debug.c send_reply(cptr, SND_EXPLICIT | RPL_STATSDEBUG, ":Hash: client %d(%zu), chan is the same", HASHSIZE, -diff -r 5ec670983aff ircd/s_err.c ---- a/ircd/s_err.c Wed Jan 28 15:15:55 2009 +0100 -+++ b/ircd/s_err.c Wed Jan 28 15:46:44 2009 +0100 +diff -r 88fea3d419e4 ircd/s_err.c +--- a/ircd/s_err.c Thu Jan 29 14:02:57 2009 +0100 ++++ b/ircd/s_err.c Thu Jan 29 19:59:36 2009 +0100 @@ -490,7 +490,7 @@ /* 228 */ { RPL_STATSQLINE, "Q %s :%s", "228" }, @@ -917,9 +935,9 @@ diff -r 5ec670983aff ircd/s_err.c /* 511 */ { ERR_SILELISTFULL, "%s :Your silence list is full", "511" }, /* 512 */ -diff -r 5ec670983aff ircd/s_misc.c ---- a/ircd/s_misc.c Wed Jan 28 15:15:55 2009 +0100 -+++ b/ircd/s_misc.c Wed Jan 28 15:46:44 2009 +0100 +diff -r 88fea3d419e4 ircd/s_misc.c +--- a/ircd/s_misc.c Thu Jan 29 14:02:57 2009 +0100 ++++ b/ircd/s_misc.c Thu Jan 29 19:59:36 2009 +0100 @@ -53,6 +53,7 @@ #include "s_stats.h" #include "s_user.h" @@ -952,9 +970,9 @@ diff -r 5ec670983aff ircd/s_misc.c } /* -diff -r 5ec670983aff ircd/s_serv.c ---- a/ircd/s_serv.c Wed Jan 28 15:15:55 2009 +0100 -+++ b/ircd/s_serv.c Wed Jan 28 15:46:44 2009 +0100 +diff -r 88fea3d419e4 ircd/s_serv.c +--- a/ircd/s_serv.c Thu Jan 29 14:02:57 2009 +0100 ++++ b/ircd/s_serv.c Thu Jan 29 19:59:36 2009 +0100 @@ -54,6 +54,7 @@ #include "s_misc.h" #include "s_user.h" @@ -971,9 +989,9 @@ diff -r 5ec670983aff ircd/s_serv.c welcome_burst(cptr); /* -diff -r 5ec670983aff ircd/s_stats.c ---- a/ircd/s_stats.c Wed Jan 28 15:15:55 2009 +0100 -+++ b/ircd/s_stats.c Wed Jan 28 15:46:44 2009 +0100 +diff -r 88fea3d419e4 ircd/s_stats.c +--- a/ircd/s_stats.c Thu Jan 29 14:02:57 2009 +0100 ++++ b/ircd/s_stats.c Thu Jan 29 19:59:36 2009 +0100 @@ -52,6 +52,7 @@ #include "s_stats.h" #include "s_user.h" @@ -994,10 +1012,10 @@ diff -r 5ec670983aff ircd/s_stats.c stats_sline, 0, "Spoofed hosts information." }, { 'T', "motds", (STAT_FLAG_OPERFEAT | STAT_FLAG_CASESENS), FEAT_HIS_STATS_T, -diff -r 5ec670983aff ircd/split.c +diff -r 88fea3d419e4 ircd/split.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 -+++ b/ircd/split.c Wed Jan 28 15:46:44 2009 +0100 -@@ -0,0 +1,788 @@ ++++ b/ircd/split.c Thu Jan 29 19:59:36 2009 +0100 +@@ -0,0 +1,873 @@ +/* + * IRC - Internet Relay Chat, ircd/split.c + * Copyright (C) 1990 Jarkko Oikarinen and @@ -1020,7 +1038,6 @@ diff -r 5ec670983aff ircd/split.c + */ +/** @file + * @brief Implementation of split server handling functions. -+ * @version $Id: split.c 1633 2006-03-25 03:46:56Z entrope $ + */ +#include "config.h" + @@ -1067,26 +1084,30 @@ diff -r 5ec670983aff ircd/split.c + unsigned int flags) +{ + struct Split *asplit; ++ char sp_server[HOSTLEN+1]; ++ char sp_reason[TOPICLEN+1]; + -+ asplit = (struct Split*) MyMalloc(sizeof(struct Split)); /* alloc memory */ ++ /* alloc memory */ ++ asplit = (struct Split*) MyMalloc(sizeof(struct Split)); ++ ++ /* we should have it now */ + assert(0 != asplit); + + memset(asplit, 0, sizeof(*asplit)); -+ /* TODO: some limit for servername length? HOSTLEN? */ -+ DupString(asplit->sp_server, server); /* copy vital information */ -+ /* TODO: some limit for reason length? QUITLEN TOPICLEN? */ ++ ircd_strncpy(sp_server, server, HOSTLEN); ++ DupString(asplit->sp_server, sp_server); + /* TODO: prefix the reason here with the opername/ID? */ -+ DupString(asplit->sp_reason, reason); -+ /* TODO: what we use creation for and do we need it? */ ++ ircd_strncpy(sp_reason, reason, TOPICLEN); ++ DupString(asplit->sp_reason, sp_reason); + asplit->sp_creation = creation; + asplit->sp_expire = expire; -+ /* TODO: are we using nettime etc.? CurrentTime is used. */ -+ /* TODO: TStime() is CurrentTime + TSoffset */ + asplit->sp_lastmod = lastmod; + asplit->sp_lifetime = lifetime; -+ asplit->sp_flags = flags & SPLIT_ACTIVE; /* set split flags */ ++ /* set split flags - only save SPLIT_ACTIVE */ ++ asplit->sp_flags = flags & SPLIT_ACTIVE; + -+ asplit->sp_next = GlobalSplitList; /* link it into the list */ ++ /* link it into the list */ ++ asplit->sp_next = GlobalSplitList; + asplit->sp_prev_p = &GlobalSplitList; + if (GlobalSplitList) + GlobalSplitList->sp_prev_p = &asplit->sp_next; @@ -1110,8 +1131,7 @@ diff -r 5ec670983aff ircd/split.c + SplitIsActive(split) && !SplitIsRemoving(split) ? '+' : '-', /* always !- not !+ */ + split->sp_server, split->sp_creation, split->sp_expire, + split->sp_lastmod, split->sp_lifetime, -+ /* TODO: does reason ? reason : split->sp_reason work too? */ -+ reason != NULL ? reason : split->sp_reason); ++ EmptyString(reason) ? split->sp_reason : reason); +} + +/** Add a new server split entry. @@ -1130,15 +1150,15 @@ diff -r 5ec670983aff ircd/split.c + unsigned int flags) +{ + -+ struct Split *asplit; -+ struct Client *acptr; ++ struct Split *split; + char noreason[BUFSIZE]; ++ static time_t rate; + -+ assert(0 != cptr); -+ assert(0 != sptr); -+ assert(0 != server); -+ assert(0 != reason); ++ assert(NULL != cptr); ++ assert(NULL != sptr); ++ assert(NULL != server); + ++ /* debug */ + Debug((DEBUG_DEBUG, "split_add(\"%s\", \"%s\", \"%s\", \"%s\", %Tu, %Tu, %Tu, " + "%Tu, 0x%04x)", cli_name(cptr), cli_name(sptr), server, reason, + creation, expire, lastmod, lifetime, flags)); @@ -1148,10 +1168,10 @@ diff -r 5ec670983aff ircd/split.c + * otherwise ignore - SERVER and SPLIT messages can cross, + * or a server is bursting and it will see our end and destroy the SPLITs + */ -+ if ((acptr = FindServer(server))) { ++ if (FindServer(server)) { + if (MyUser(sptr)) + sendcmdto_one(&me, CMD_NOTICE, sptr, -+ "%C :Cannot add SPLIT %s - server is linked.", sptr, server); ++ "%C :SPLIT: Cannot add SPLIT %s - server is linked.", sptr, server); + return 0; + } + @@ -1160,7 +1180,6 @@ diff -r 5ec670983aff ircd/split.c + * duration greater than SPLIT_MAX_EXPIRE. + */ + if (expire - TStime() <= 0 || expire - TStime() > SPLIT_MAX_EXPIRE) { -+ /* TODO: cptr or sptr here? */ + if (MyUser(sptr)) + return send_reply(cptr, ERR_BADEXPIRE, expire - TStime()); + if (lifetime <= TStime()) /* no point going further */ @@ -1172,29 +1191,41 @@ diff -r 5ec670983aff ircd/split.c + } + + /* empty reason */ -+ if (reason[0] == '\0') ++ if (EmptyString(reason)) + ircd_snprintf(0, noreason, sizeof(noreason), "%C gave no reason.", sptr); + -+ /* inform ops and log it */ ++ /* lastmod is more than SPLIT_MAX_DRIFT seconds ahead of our idea of time ++ * correct and warn ops ++ */ ++ if (lastmod - TStime() > SPLIT_MAX_DRIFT) { ++ sendto_opmask_butone_ratelimited(0, SNO_NETWORK, &rate, ++ "Possible timestamp drift from %C; lastmod in SPLIT message is %is ahead of time", ++ IsServer(sptr) ? sptr : cli_user(sptr)->server, lastmod - TStime()); ++ lastmod = TStime() + SPLIT_MAX_DRIFT; ++ } ++ ++ /* make the split entry */ ++ split = split_make(server, EmptyString(reason) ? noreason : reason, ++ creation, expire, lastmod, lifetime, flags); ++ ++ /* got to have it now */ ++ assert(split); ++ ++ /* inform ops */ + sendto_opmask_butone(0, SNO_NETWORK, "%s adding%sSPLIT for %s, expiring at %Tu: %s", + (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ? + get_client_name_and_opername(sptr) : cli_name((cli_user(sptr))->server), -+ !(flags & SPLIT_ACTIVE) ? " deactivated " : " ", -+ server, expire, reason[0] == '\0' ? noreason : reason); ++ SplitIsActive(split) ? " " : " deactivated ", ++ split->sp_server, split->sp_expire, split->sp_reason); + ++ /* log it */ + log_write(LS_SPLIT, L_INFO, LOG_NOSNOTICE, + "%#C adding%sSPLIT for %s, expiring at %Tu: %s", -+ sptr, !(flags & SPLIT_ACTIVE) ? " deactivated " : " ", -+ server, expire, reason[0] == '\0' ? noreason : reason); -+ -+ /* make the split entry */ -+ asplit = split_make(server, reason[0] == '\0' ? noreason : reason, -+ creation, expire, lastmod, lifetime, flags); -+ -+ assert(asplit); ++ sptr, SplitIsActive(split) ? " " : " deactivated ", ++ split->sp_server, split->sp_expire, split->sp_reason); + + /* and propagate it */ -+ split_propagate(cptr, sptr, asplit, NULL); ++ split_propagate(cptr, sptr, split, NULL); + + return 0; +} @@ -1204,7 +1235,7 @@ diff -r 5ec670983aff ircd/split.c + * @param[in] cptr Client that sent us the split modification. + * @param[in] sptr Client that originated the split modification. + * @param[in] split Split entry being modified. -+ * @param[in] action Resultant status of the G-line. ++ * @param[in] action Resultant status of the SPLIT. + * @param[in] reason Reason. + * @param[in] expire Expiration time. + * @param[in] lastmod Last modification time. @@ -1218,14 +1249,16 @@ diff -r 5ec670983aff ircd/split.c + time_t creation, time_t expire, time_t lastmod, time_t lifetime, + unsigned int flags) +{ -+ struct Client* acptr; + char buf[BUFSIZE]; ++ char sp_reason[TOPICLEN+1]; + int pos = 0; ++ static time_t rate; + -+ assert(0 != cptr); -+ assert(0 != sptr); -+ assert(0 != split); ++ assert(NULL != cptr); ++ assert(NULL != sptr); ++ assert(NULL != split); + ++ /* debug */ + Debug((DEBUG_DEBUG, "split_modify(cptr \"%s\", sptr \"%s\", split \"%s\", reason \"%s\"," + " action %d, creation %Tu, expire %Tu, lastmod %Tu, lifetime %Tu, flags 0x%04x)", + cli_name(cptr), cli_name(sptr), split->sp_server, reason, action, @@ -1241,25 +1274,55 @@ diff -r 5ec670983aff ircd/split.c + * we can get SPLITs for a linked server. + * also more than one server can be bursting at a time. + */ -+ if ((acptr = FindServer(split->sp_server))) { ++ if (FindServer(split->sp_server)) { + if (MyUser(sptr)) + sendcmdto_one(&me, CMD_NOTICE, sptr, -+ "%C :Cannot modify SPLIT %s - server is linked.", sptr, split->sp_server); -+ /* SPLIT is not for a server part of a netmerge */ ++ "%C :SPLIT: Cannot modify SPLIT %s - server is linked.", sptr, split->sp_server); ++ ++ /* SPLIT is not for a server part of a netmerge - free it */ + if (!SplitIsBurst(split)) -+ split_free(split); /* and free it */ ++ split_free(split); + return 0; + } + + /* check lastmod */ -+ if (split->sp_lastmod > lastmod) { /* we have a more recent version */ -+ if (IsBurstOrBurstAck(cptr)) /* middle of a burst, it will resync on its own */ ++ /* check if my oper modifies the SPLIT ++ * in which case use the greater of lastmod and split->sp_lastmod+1 ++ * ++ * because if the lastmod of the split is in the future (greater than TStime()) ++ * my oper cannot modify it when we use TStime() as lastmod ++ * therefore use split->sp_lastmod+1 - ugly hack, but the only way in that situation ++ * to modify it, apart from force removing it first.. ++ */ ++ if (MyUser(sptr)) ++ lastmod = IRCD_MAX(lastmod, split->sp_lastmod + 1); ++ /* we have a more recent version */ ++ if (split->sp_lastmod > lastmod) { ++ /* middle of a burst, it will resync on its own */ ++ if (IsBurstOrBurstAck(cptr)) + return 0; -+ return split_resend(cptr, split); /* resync the server */ -+ } else if (split->sp_lastmod == lastmod) /* same version */ ++ /* resync the server */ ++ return split_resend(cptr, split); ++ /* same version */ ++ } else if (split->sp_lastmod == lastmod) + return 0; -+ -+ /* there is a change of some sort */ ++ ++ /* lastmod is more than SPLIT_MAX_DRIFT seconds ahead of our idea of time ++ * correct and warn ops ++ * ++ * not in case it is my oper ++ * we use the lastmod of either TStime() or the lastmod we have plus 1 second ++ * see above ++ */ ++ if (lastmod - TStime() > SPLIT_MAX_DRIFT && !MyUser(sptr)) { ++ sendto_opmask_butone_ratelimited(0, SNO_NETWORK, &rate, ++ "Possible timestamp drift from %C; lastmod in SPLIT message is %is ahead of time", ++ IsServer(sptr) ? sptr : cli_user(sptr)->server, lastmod - TStime()); ++ lastmod = TStime() + SPLIT_MAX_DRIFT; ++ } ++ ++ /* we got here so there is a change of some sort */ ++ + /* check out the expiration time */ + if (flags & SPLIT_EXPIRE) { + if (expire != split->sp_expire) { @@ -1273,72 +1336,82 @@ diff -r 5ec670983aff ircd/split.c + flags &= ~SPLIT_EXPIRE; + } + -+ /* Next, check out lifetime */ ++ /* check out lifetime */ + if (!(flags & SPLIT_LIFETIME) || !lifetime) + lifetime = split->sp_lifetime; /* use Split lifetime */ + -+ lifetime = IRCD_MAX(lifetime, expire); /* set lifetime to the max */ ++ /* raise lifetime when required */ ++ lifetime = IRCD_MAX(lifetime, expire); + -+ /* now that we have the correct lifetime, check it */ -+ if (lifetime - TStime() <= 0) /* no point in going further */ ++ /* SPLIT already expired with this lifetime */ ++ if (lifetime - TStime() <= 0) + return 0; + -+ /* OK, let's see which is greater... */ ++ /* check if lifetime needs to be updated */ + if (lifetime > split->sp_lifetime) -+ flags |= SPLIT_LIFETIME; /* have to update lifetime */ ++ flags |= SPLIT_LIFETIME; + else { -+ flags &= ~SPLIT_LIFETIME; /* no change to lifetime */ ++ flags &= ~SPLIT_LIFETIME; + lifetime = 0; + } + -+ /* Finally, let's see if the reason needs to be updated */ -+ if ((flags & SPLIT_REASON) && (reason[0] == '\0' || !ircd_strcmp(split->sp_reason, reason))) -+ flags &= ~SPLIT_REASON; /* no changes to the reason */ ++ /* no changes to the reason - empty or the same */ ++ if ((flags & SPLIT_REASON) && ++ (EmptyString(reason) || !ircd_strcmp(split->sp_reason, reason))) ++ flags &= ~SPLIT_REASON; + -+ /* OK, now let's take a look at the action... */ ++ /* no status change ++ * activate but split is active ++ * deactivate but split is deactivated ++ * expire timestamp is in the past so it should be deactivated ++ * and cannot be activated anymore ++ */ + if ((action == SPLIT_ACTIVATE && SplitIsActive(split)) || + (action == SPLIT_DEACTIVATE && !SplitIsActive(split)) || -+ /* can't activate an expired split entry */ + (IRCD_MAX(split->sp_expire, expire) <= TStime())) -+ action = SPLIT_MODIFY; /* no activity state modifications */ ++ action = SPLIT_MODIFY; + ++ /* debug */ + Debug((DEBUG_DEBUG, "About to perform changes; flags 0x%04x, action %s", + flags, action == SPLIT_ACTIVATE ? "SPLIT_ACTIVATE" : + (action == SPLIT_DEACTIVATE ? "SPLIT_DEACTIVATE" : + (action == SPLIT_MODIFY ? "SPLIT_MODIFY" : "")))); + -+ /* If there are no changes to perform, do no changes */ ++ /* nothing to change at all */ + if (!(flags & SPLIT_UPDATE) && action == SPLIT_MODIFY) { + if (MyUser(sptr)) + sendcmdto_one(&me, CMD_NOTICE, sptr, -+ "%C :Cannot modify SPLIT %s - nothing to change.", sptr, split->sp_server); ++ "%C :SPLIT: Cannot modify SPLIT %s - nothing to change.", sptr, split->sp_server); + return 0; + } + -+ /* Start by updating lastmod, if indicated... */ ++ /* update lastmod */ + split->sp_lastmod = lastmod; + -+ /* Then move on to activity status changes... */ ++ /* update status */ + switch (action) { -+ case SPLIT_ACTIVATE: /* activating split entry */ -+ split->sp_flags |= SPLIT_ACTIVE; /* make it active... */ ++ ++ /* activating split entry */ ++ case SPLIT_ACTIVATE: ++ split->sp_flags |= SPLIT_ACTIVE; + pos += ircd_snprintf(0, buf, sizeof(buf), " activating SPLIT"); + break; + -+ case SPLIT_DEACTIVATE: /* deactivating split entry */ -+ split->sp_flags &= ~SPLIT_ACTIVE; /* make it inactive... */ ++ /* deactivating split entry */ ++ case SPLIT_DEACTIVATE: ++ split->sp_flags &= ~SPLIT_ACTIVE; + pos += ircd_snprintf(0, buf, sizeof(buf), " deactivating SPLIT"); + break; + -+ case SPLIT_MODIFY: /* no change to activity status */ ++ /* no change to activity status */ ++ case SPLIT_MODIFY: + break; + } + -+ /* TODO: Handle creation changes... */ + -+ /* Handle expiration changes... */ ++ /* update expire */ + if (flags & SPLIT_EXPIRE) { -+ split->sp_expire = expire; /* save new expiration time */ ++ split->sp_expire = expire; + if (pos < BUFSIZE) + pos += ircd_snprintf(0, buf + pos, sizeof(buf) - pos, + "%s%s changing expiration time to %Tu", @@ -1347,9 +1420,9 @@ diff -r 5ec670983aff ircd/split.c + " and" : "", expire); + } + -+ /* Next, handle lifetime changes... */ ++ /* update lifetime */ + if (flags & SPLIT_LIFETIME) { -+ split->sp_lifetime = lifetime; /* save new lifetime */ ++ split->sp_lifetime = lifetime; + if (pos < BUFSIZE) + pos += ircd_snprintf(0, buf + pos, sizeof(buf) - pos, + "%s%s extending record lifetime to %Tu", @@ -1357,23 +1430,24 @@ diff -r 5ec670983aff ircd/split.c + " and" : "", lifetime); + } + -+ /* Now, handle reason changes... */ ++ /* update reason */ + if (flags & SPLIT_REASON) { -+ MyFree(split->sp_reason); /* release old reason */ -+ DupString(split->sp_reason, reason); /* store new reason */ ++ MyFree(split->sp_reason); ++ ircd_strncpy(sp_reason, reason, TOPICLEN); ++ DupString(split->sp_reason, sp_reason); + if (pos < BUFSIZE) + pos += ircd_snprintf(0, buf + pos, sizeof(buf) - pos, + "%s%s changing reason to \"%s\"", -+ pos ? ";" : "", pos ? " and" : "", reason); ++ pos ? ";" : "", pos ? " and" : "", sp_reason); + } + -+ /* All right, inform ops... */ ++ /* inform ops */ + sendto_opmask_butone(0, SNO_NETWORK, "%s modifying SPLIT for %s:%s", + (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ? + get_client_name_and_opername(sptr) : cli_name((cli_user(sptr))->server), + split->sp_server, buf); + -+ /* and log the change */ ++ /* log it */ + log_write(LS_SPLIT, L_INFO, LOG_NOSNOTICE, + "%#C modifying SPLIT for %s:%s", + sptr, split->sp_server, buf); @@ -1397,10 +1471,11 @@ diff -r 5ec670983aff ircd/split.c +{ + unsigned int saveflags = 0; + -+ assert(0 != split); ++ assert(NULL != split); + assert(NULL != cptr); + assert(NULL != sptr); + ++ /* debug */ + Debug((DEBUG_DEBUG, "split_remove(\"%s\", \"%s\", \"%s\", \"%s\")", + cli_name(cptr), cli_name(sptr), split->sp_server, reason)); + @@ -1408,12 +1483,13 @@ diff -r 5ec670983aff ircd/split.c + split->sp_flags |= SPLIT_REMOVING; + split->sp_flags &= ~SPLIT_ACTIVE; + -+ /* inform ops and log it */ ++ /* inform ops */ + sendto_opmask_butone(0, SNO_NETWORK, "%s removing SPLIT for %s, expiring at %Tu: %s (%s)", + (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ? + get_client_name_and_opername(sptr) : cli_name((cli_user(sptr))->server), + split->sp_server, split->sp_expire, split->sp_reason, reason); + ++ /* log it */ + log_write(LS_SPLIT, L_INFO, LOG_NOSNOTICE, + "%#C removing SPLIT for %s, expiring at %Tu: %s (%s)", + sptr, split->sp_server, split->sp_expire, split->sp_reason, reason); @@ -1438,16 +1514,21 @@ diff -r 5ec670983aff ircd/split.c + struct Split* split; + struct Split* ssplit; + -+ for (split = GlobalSplitList; split; split = ssplit) { /* go through splits */ ++ /* go over SPLITs */ ++ for (split = GlobalSplitList; split; split = ssplit) { + ssplit = split->sp_next; + -+ if (split_expire(split)) /* expire any that need expiring */ ++ /* expire any that need expiring */ ++ if (split_expire(split)) + split_free(split); -+ else if (0 == ircd_strcmp(server, split->sp_server)) /* found it yet? */ ++ ++ /* found it */ ++ else if (0 == ircd_strcmp(server, split->sp_server)) + return split; + } -+ /* TODO: we return 0 not NULL? */ -+ return 0; ++ ++ /* nothing found */ ++ return NULL; +} + +/** Unlink and free an unused split entry. @@ -1456,15 +1537,15 @@ diff -r 5ec670983aff ircd/split.c +void +split_free(struct Split* split) +{ -+ /* TODO: use 0 or NULL ? */ -+ assert(0 != split); ++ assert(NULL != split); + -+ *split->sp_prev_p = split->sp_next; /* squeeze this split entry out */ ++ /* squeeze this split entry out */ ++ *split->sp_prev_p = split->sp_next; + if (split->sp_next) + split->sp_next->sp_prev_p = split->sp_prev_p; + -+ /* CHECK: the other fields in this struct are destroyed with MyFree() call? */ -+ MyFree(split->sp_server); /* and free up the memory */ ++ /* and free up the memory */ ++ MyFree(split->sp_server); + MyFree(split->sp_reason); + MyFree(split); +} @@ -1478,7 +1559,7 @@ diff -r 5ec670983aff ircd/split.c +int +split_expire(struct Split* split) +{ -+ assert(0 != split); ++ assert(NULL != split); + + /* TODO: also check if the server in SPLIT entry is linked atm? */ + /* past lifetime */ @@ -1503,23 +1584,28 @@ diff -r 5ec670983aff ircd/split.c + + assert(NULL != cptr); + -+ for (split = GlobalSplitList; split; split = ssplit) { /* go through splits */ ++ /* go over SPLITs */ ++ for (split = GlobalSplitList; split; split = ssplit) { + ssplit = split->sp_next; + + /* expire any that need expiring */ -+ if (split_expire(split)) ++ if (split_expire(split)) { + split_free(split); ++ continue; ++ } ++ + /* if we have an entry for cptr, dont send it - but do not free here yet + * free it at end of burst, to get the correct count for SPLITs removed. + */ -+ else if (ircd_strcmp(split->sp_server, cli_name(cptr)) == 0) ++ if (ircd_strcmp(split->sp_server, cli_name(cptr)) == 0) + continue; -+ else -+ sendcmdto_one(&me, CMD_SPLIT, cptr, "%c%s %Tu %Tu %Tu %Tu :%s", -+ SplitIsActive(split) ? '+' : '-', split->sp_server, -+ split->sp_creation, split->sp_expire, -+ split->sp_lastmod, split->sp_lifetime, -+ split->sp_reason); ++ ++ /* send it */ ++ sendcmdto_one(&me, CMD_SPLIT, cptr, "%c%s %Tu %Tu %Tu %Tu :%s", ++ SplitIsActive(split) ? '+' : '-', split->sp_server, ++ split->sp_creation, split->sp_expire, ++ split->sp_lastmod, split->sp_lifetime, ++ split->sp_reason); + } +} + @@ -1540,7 +1626,7 @@ diff -r 5ec670983aff ircd/split.c + return 0; +} + -+/** Send a split entry (or a list of split entries) to a server. ++/** List split entries to a client. + * @param[in] sptr Client searching for split entries. + * @param[in] server Name of split entry to search for (if NULL, list all). + * @return Zero. @@ -1555,12 +1641,18 @@ diff -r 5ec670983aff ircd/split.c + + /* go through SPLITs */ + for (split = GlobalSplitList; split; split = split->sp_next) { -+ if (split_expire(split)) { /* expire any that need expiring */ ++ ++ /* expire any that need expiring */ ++ if (split_expire(split)) { + split_free(split); + continue; + } ++ ++ /* server given and does not match */ + if (server && match(server, split->sp_server)) + continue; ++ ++ /* got one */ + count++; + send_reply(sptr, RPL_SPLITLIST, split->sp_server, + split->sp_creation, split->sp_expire, split->sp_lastmod, split->sp_lifetime, @@ -1586,18 +1678,19 @@ diff -r 5ec670983aff ircd/split.c + + assert(NULL != acptr); + ++ /* debug */ + Debug((DEBUG_DEBUG, "split_newserver(\"%s\")", cli_name(acptr))); + + /* mark the SPLIT with SPLIT_BURST + * so we know this SPLIT is marked for removal already + * but not remove it just yet to get the correct count + * of SPLITs removed at the end of burst. ++ * + * also we need the SPLIT in case the net breaks again + * before end of burst? + */ + if ((split = split_find(cli_name(acptr)))) + split->sp_flags |= SPLIT_BURST; -+ return; +} + + @@ -1614,6 +1707,7 @@ diff -r 5ec670983aff ircd/split.c + + assert(NULL != sptr); + ++ /* debug */ + Debug((DEBUG_DEBUG, "split_netmerge(\"%s\")", cli_name(sptr))); + + /* find the SPLIT for this server */ @@ -1625,6 +1719,8 @@ diff -r 5ec670983aff ircd/split.c + /* go over its downlinks */ + for (lp = cli_serv(sptr)->down; lp; lp = lp->next) + count += split_netmerge(lp->value.cptr); ++ ++ /* return the number of SPLITs removed */ + return count; +} + @@ -1646,6 +1742,7 @@ diff -r 5ec670983aff ircd/split.c + + assert(NULL != victim); + ++ /* debug */ + Debug((DEBUG_DEBUG, "split_netbreak(\"%s\", \"%s\")", cli_name(victim), reason)); + + /* bad auto expire value */ @@ -1663,11 +1760,14 @@ diff -r 5ec670983aff ircd/split.c + split_make(cli_name(victim), reason, creation, expire, lastmod, lifetime, flags); + count++; + } else -+ split->sp_flags &= SPLIT_BURST; /* clear the burst flag for it */ ++ /* clear the burst flag for it */ ++ split->sp_flags &= SPLIT_BURST; + + /* go over its downlinks */ + for (lp = cli_serv(victim)->down; lp; lp = lp->next) + count += split_netbreak(lp->value.cptr, reason); ++ ++ /* return the number of SPLITs created */ + return count; +} + @@ -1685,6 +1785,7 @@ diff -r 5ec670983aff ircd/split.c + unsigned int flags = SPLIT_ACTIVE; + char reason[BUFSIZE]; + ++ /* debug */ + Debug((DEBUG_DEBUG, "split_conf()")); + + /* we are not set to generate SPLITs */ @@ -1720,17 +1821,19 @@ diff -r 5ec670983aff ircd/split.c + * /REHASH goes to SNO_OLDSNO? so this too? + * if oper did rehash, add his name here? + */ -+ /* inform ops and log it */ ++ /* inform ops */ + sendto_opmask_butone(0, SNO_NETWORK, "%C adding SPLIT for %s, expiring at %Tu: %s", + &me, conf->name, expire, reason); + ++ /* log it */ + log_write(LS_SPLIT, L_INFO, LOG_NOSNOTICE, + "%C adding SPLIT for %s, expiring at %Tu: %s", + &me, conf->name, expire, reason); + + /* make the split entry */ + split = split_make(conf->name, reason, creation, expire, lastmod, lifetime, flags); -+ ++ ++ /* got to have it now */ + assert(split); + + /* and propagate it */ @@ -1753,6 +1856,7 @@ diff -r 5ec670983aff ircd/split.c + send_reply(sptr, SND_EXPLICIT | RPL_STATSHEADER, + "S Server Creation Expire Lastmod Lifetime Status :Reason"); + ++ /* go over SPLIT entries */ + for (split = GlobalSplitList; split; split = split->sp_next) { + + /* does not match */ @@ -1785,4 +1889,3 @@ diff -r 5ec670983aff ircd/split.c + } + return sp; +} -+