From ef341b1f6d4389eee8b1d7ef5bb926d7cfab0816 Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Tue, 14 Jul 2015 15:23:28 +0200 Subject: [PATCH] Link to servers faster after boot. Check links for re-linking more often. Allow connfreq of 5 seconds. Set default to 15. Get rid of HANGONGOODLINK/HANGONRETRYDELAY stuff. --- doc/conf/examples/example.conf | 2 +- include/config.h | 12 ------- include/struct.h | 6 ++-- src/events.c | 2 +- src/ircd.c | 58 +++++++++++++--------------------- src/s_bsd.c | 24 -------------- src/s_conf.c | 6 ++-- 7 files changed, 30 insertions(+), 80 deletions(-) diff --git a/doc/conf/examples/example.conf b/doc/conf/examples/example.conf index ebfd4b4fa..bec083914 100644 --- a/doc/conf/examples/example.conf +++ b/doc/conf/examples/example.conf @@ -101,7 +101,7 @@ class opers class servers { pingfreq 60; - connfreq 30; /* try to connect every 30 seconds */ + connfreq 15; /* try to connect every 15 seconds */ maxclients 10; /* max servers */ sendq 5M; }; diff --git a/include/config.h b/include/config.h index e51c8d1f8..a1250f27c 100644 --- a/include/config.h +++ b/include/config.h @@ -421,18 +421,6 @@ */ #define PINGFREQUENCY 120 /* Recommended value: 120 */ -/* - * Often net breaks for a short time and it's useful to try to - * establishing the same connection again faster than CONNECTFREQUENCY - * would allow. But, to keep trying on bad connection, we require - * that connection has been open for certain minimum time - * (HANGONGOODLINK) and we give the net few seconds to steady - * (HANGONRETRYDELAY). This latter has to be long enough that the - * other end of the connection has time to notice it broke too. - */ -#define HANGONRETRYDELAY 20 /* Recommended value: 20 seconds */ -#define HANGONGOODLINK 300 /* Recommended value: 5 minutes */ - /* * Number of seconds to wait for write to complete if stuck. */ diff --git a/include/struct.h b/include/struct.h index d80d1d786..2ee9cea01 100644 --- a/include/struct.h +++ b/include/struct.h @@ -1221,9 +1221,9 @@ struct _configitem_deny_dcc { }; struct _configitem_deny_link { - ConfigItem *prev, *next; - ConfigFlag_except flag; - char *mask, *rule, *prettyrule; + ConfigItem_deny_link *prev, *next; + ConfigFlag_except flag; + char *mask, *rule, *prettyrule; }; struct _configitem_deny_version { diff --git a/src/events.c b/src/events.c index d1e28ba4f..06cd88697 100644 --- a/src/events.c +++ b/src/events.c @@ -216,7 +216,7 @@ void SetupEvents(void) EventAddEx(NULL, "check_pings", 1, 0, check_pings, NULL); EventAddEx(NULL, "check_deadsockets", 1, 0, check_deadsockets, NULL); EventAddEx(NULL, "check_unknowns", 16, 0, check_unknowns, NULL); - EventAddEx(NULL, "try_connections", 10, 0, try_connections, NULL); + EventAddEx(NULL, "try_connections", 2, 0, try_connections, NULL); UnlockEventSystem(); } diff --git a/src/ircd.c b/src/ircd.c index 8e5a3d4c8..c32a919f8 100644 --- a/src/ircd.c +++ b/src/ircd.c @@ -404,52 +404,38 @@ EVENT(try_connections) ConfigItem_deny_link *deny; aClient *cptr; int confrq; - ConfigItem_class *cltmp; + ConfigItem_class *class; - for (aconf = conf_link; aconf; aconf = (ConfigItem_link *) aconf->next) { - /* - * Also when already connecting! (update holdtimes) --SRB - */ + for (aconf = conf_link; aconf; aconf = (ConfigItem_link *) aconf->next) + { + /* We're only interested in autoconnect blocks that are valid (and ignore temporary link blocks) */ if (!(aconf->outgoing.options & CONNECT_AUTO) || !aconf->outgoing.hostname || (aconf->flag.temporary == 1)) continue; - cltmp = aconf->class; - /* - * ** Skip this entry if the use of it is still on hold until - * ** future. Otherwise handle this entry (and set it on hold - * ** until next time). Will reset only hold times, if already - * ** made one successfull connection... [this algorithm is - * ** a bit fuzzy... -- msa >;) ] - */ - + class = aconf->class; + + /* Only do one connection attempt per seconds (for the same server) */ if ((aconf->hold > TStime())) continue; - - confrq = cltmp->connfreq; + confrq = class->connfreq; aconf->hold = TStime() + confrq; - /* - * ** Found a CONNECT config with port specified, scan clients - * ** and see if this server is already connected? - */ - cptr = find_name(aconf->servername, (aClient *)NULL); - if (!cptr && (cltmp->clients < cltmp->maxclients)) { - /* - * Check connect rules to see if we're allowed to try - */ - for (deny = conf_deny_link; deny; - deny = (ConfigItem_deny_link *) deny->next) - if (!match(deny->mask, aconf->servername) - && crule_eval(deny->rule)) - break; + cptr = find_name(aconf->servername, NULL); + if (cptr) + continue; /* Server already connected (or connecting) */ - if (!deny && connect_server(aconf, (aClient *)NULL, - (struct hostent *)NULL) == 0) - sendto_realops - ("Connection to %s[%s] activated.", - aconf->servername, aconf->outgoing.hostname); + if (class->clients >= class->maxclients) + continue; /* Class is full */ + + /* Check connect rules to see if we're allowed to try the link */ + for (deny = conf_deny_link; deny; deny = deny->next) + if (!match(deny->mask, aconf->servername) && crule_eval(deny->rule)) + break; + + if (!deny && connect_server(aconf, NULL, NULL) == 0) + sendto_realops("Connection to %s[%s] activated.", + aconf->servername, aconf->outgoing.hostname); - } } } diff --git a/src/s_bsd.c b/src/s_bsd.c index bfa88af0f..d9a419950 100644 --- a/src/s_bsd.c +++ b/src/s_bsd.c @@ -861,30 +861,6 @@ void close_connection(aClient *cptr) * remove outstanding DNS queries. */ unrealdns_delreq_bycptr(cptr); - /* - * If the connection has been up for a long amount of time, schedule - * a 'quick' reconnect, else reset the next-connect cycle. - * - * Now just hold on a minute. We're currently doing this when a - * CLIENT exits too? I don't think so! If its not a server, or - * the SQUIT flag has been set, then we don't schedule a fast - * reconnect. Pisses off too many opers. :-) -Cabal95 - */ - if (IsServer(cptr) && !(cptr->flags & FLAGS_SQUIT) && cptr->serv->conf && - (!cptr->serv->conf->flag.temporary && - (cptr->serv->conf->options & CONNECT_AUTO))) - { - aconf = cptr->serv->conf; - /* - * Reschedule a faster reconnect, if this was a automaticly - * connected configuration entry. (Note that if we have had - * a rehash in between, the status has been changed to - * CONF_ILLEGAL). But only do this if it was a "good" link. - */ - aconf->hold = TStime(); - aconf->hold += (aconf->hold - cptr->since > HANGONGOODLINK) ? - HANGONRETRYDELAY : aconf->class->connfreq; - } if (cptr->authfd >= 0) { diff --git a/src/s_conf.c b/src/s_conf.c index 123269eff..5dca407c3 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -3952,7 +3952,7 @@ int _conf_class(ConfigFile *conf, ConfigEntry *ce) } safestrdup(class->name, ce->ce_vardata); - class->connfreq = 60; /* default */ + class->connfreq = 15; /* default */ for (cep = ce->ce_entries; cep; cep = cep->ce_next) { @@ -4069,9 +4069,9 @@ int _test_class(ConfigFile *conf, ConfigEntry *ce) } has_connfreq = 1; l = atol(cep->ce_vardata); - if ((l < 10) || (l > 604800)) + if ((l < 5) || (l > 604800)) { - config_error("%s:%i: class::connfreq with illegal value (must be >10 and <7d)", + config_error("%s:%i: class::connfreq with illegal value (must be >5 and <7d)", cep->ce_fileptr->cf_filename, cep->ce_varlinenum); errors++; }