From: Michael Poole Date: Mon, 15 Jan 2007 03:08:23 +0000 (+0000) Subject: Merge end-of-December changes from HEAD to u2_10_12_branch. X-Git-Url: http://git.pk910.de/?p=ircu2.10.12-pk.git;a=commitdiff_plain;h=129fc4f6d5f88a86544bf3ad1f9c3c312095ff98 Merge end-of-December changes from HEAD to u2_10_12_branch. git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/branches/u2_10_12_branch@1746 c9e4aea6-c8fd-4c43-8297-357d70d61c8c --- diff --git a/ChangeLog b/ChangeLog index b70946a..2096ac2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,28 @@ +2006-12-31 Michael Poole + + * ircd/m_mode.c (ms_mode): Bounce modes from deopped members. + +2006-12-30 Michael Poole + + * ircd/ircd_string.c (ircd_strncpy): Make sure the output buffer + is terminated. We don't rely on the arguable strncpy semantics. + +2006-12-30 Michael Poole + + * include/struct.h (struct Server): Add asll_last field. + + * ircd/ircd.c (check_pings): Add check for asll_last. When a + server doesn't ping, use an old-style ping rather than AsLL ping. + + * ircd/m_pong.c (ms_pong): Use ClearPingSent() rather than + ClrFlag(). Set asll_last to current time. + (mr_pong): Use ClearPingSent() rather than ClrFlag(). + (m_pong): Likewise. + + * ircd/s_bsd.c (completed_connection): Likewise. + (read_packet): Likewise. Update cli_lasttime for servers in + addition to clients. + 2006-01-13 Michael Poole * ircd/m_burst.c (ms_burst): Properly handle member mode :ov. diff --git a/include/struct.h b/include/struct.h index b704166..cd2712c 100644 --- a/include/struct.h +++ b/include/struct.h @@ -57,6 +57,7 @@ struct Server { int asll_rtt; /**< AsLL round-trip time */ int asll_to; /**< AsLL upstream lag */ int asll_from; /**< AsLL downstream lag */ + time_t asll_last; /**< Last time we sent or received an AsLL ping */ char *last_error_msg; /**< Allocated memory with last message receive with an ERROR */ char by[NICKLEN + 1]; /**< Numnick of client who requested the link */ diff --git a/ircd/ircd.c b/ircd/ircd.c index 8503d0c..006263b 100644 --- a/ircd/ircd.c +++ b/ircd/ircd.c @@ -356,6 +356,24 @@ static void check_pings(struct Event* ev) { IsPingSent(cptr) ? "[Ping Sent]" : "[]", max_ping, (int)(CurrentTime - cli_lasttime(cptr)))); + /* If it's a server and we have not sent an AsLL lately, do so. */ + if (IsServer(cptr)) { + if (CurrentTime - cli_serv(cptr)->asll_last >= max_ping) { + char *asll_ts; + + SetPingSent(cptr); + cli_serv(cptr)->asll_last = CurrentTime; + expire = cli_serv(cptr)->asll_last + max_ping; + asll_ts = militime_float(NULL); + sendcmdto_prio_one(&me, CMD_PING, cptr, "!%s %s %s", asll_ts, + cli_name(cptr), asll_ts); + } + + expire = cli_serv(cptr)->asll_last + max_ping; + if (expire < next_check) + next_check = expire; + } + /* Ok, the thing that will happen most frequently, is that someone will * have sent something recently. Cover this first for speed. * -- @@ -418,11 +436,7 @@ static void check_pings(struct Event* ev) { if (IsUser(cptr)) sendrawto_one(cptr, MSG_PING " :%s", cli_name(&me)); else - { - char *asll_ts = militime_float(NULL); - sendcmdto_one(&me, CMD_PING, cptr, "!%s %s %s", asll_ts, - cli_name(cptr), asll_ts); - } + sendcmdto_prio_one(&me, CMD_PING, cptr, ":%s", cli_name(&me)); } expire = cli_lasttime(cptr) + max_ping * 2; diff --git a/ircd/ircd_string.c b/ircd/ircd_string.c index 52caed5..a9d9451 100644 --- a/ircd/ircd_string.c +++ b/ircd/ircd_string.c @@ -156,6 +156,8 @@ char* ircd_strncpy(char* s1, const char* s2, size_t n) while (s < endp && (*s++ = *s2++)) ; + if (s == endp) + *s = '\0'; return s1; } diff --git a/ircd/m_mode.c b/ircd/m_mode.c index ca366cc..cb27ee5 100644 --- a/ircd/m_mode.c +++ b/ircd/m_mode.c @@ -197,7 +197,7 @@ ms_mode(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) MODE_PARSE_FORCE), /* And force it to be accepted */ NULL); } else { - if (!(member = find_member_link(chptr, sptr))) { + if (!(member = find_member_link(chptr, sptr)) || !IsChanOp(member)) { modebuf_init(&mbuf, sptr, cptr, chptr, (MODEBUF_DEST_SERVER | /* Send mode to server */ MODEBUF_DEST_HACK2 | /* Send a HACK(2) message */ diff --git a/ircd/m_pong.c b/ircd/m_pong.c index 9cae0c0..df29b9f 100644 --- a/ircd/m_pong.c +++ b/ircd/m_pong.c @@ -119,8 +119,8 @@ int ms_pong(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) } origin = parv[1]; destination = parv[2]; - ClrFlag(cptr, FLAG_PINGSENT); - ClrFlag(sptr, FLAG_PINGSENT); + ClearPingSent(cptr); + ClearPingSent(sptr); cli_lasttime(cptr) = CurrentTime; if (parc > 5) @@ -129,6 +129,7 @@ int ms_pong(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) cli_serv(cptr)->asll_rtt = atoi(militime_float(parv[3])); cli_serv(cptr)->asll_to = atoi(parv[4]); cli_serv(cptr)->asll_from = atoi(militime_float(parv[5])); + cli_serv(cptr)->asll_last = CurrentTime; return 0; } @@ -162,7 +163,7 @@ int mr_pong(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) assert(cptr == sptr); assert(!IsRegistered(sptr)); - ClrFlag(cptr, FLAG_PINGSENT); + ClearPingSent(cptr); return (parc > 1) ? auth_set_pong(cli_auth(sptr), strtoul(parv[parc - 1], NULL, 10)) : 0; } @@ -178,7 +179,7 @@ int m_pong(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) assert(0 != cptr); assert(cptr == sptr); - ClrFlag(cptr, FLAG_PINGSENT); + ClearPingSent(cptr); cli_lasttime(cptr) = CurrentTime; return 0; } diff --git a/ircd/os_generic.c b/ircd/os_generic.c index 72fba12..1c6489b 100644 --- a/ircd/os_generic.c +++ b/ircd/os_generic.c @@ -450,9 +450,13 @@ IOResult os_recv_nonb(int fd, char* buf, unsigned int length, if (0 < (res = recv(fd, buf, length, 0))) { *count_out = (unsigned) res; return IO_SUCCESS; + } else if (res == 0) { + *count_out = 0; + errno = 0; /* or ECONNRESET? */ + return IO_FAILURE; } else { *count_out = 0; - return (res < 0) && is_blocked(errno) ? IO_BLOCKED : IO_FAILURE; + return is_blocked(errno) ? IO_BLOCKED : IO_FAILURE; } } diff --git a/ircd/s_bsd.c b/ircd/s_bsd.c index 71706e5..3989ca0 100644 --- a/ircd/s_bsd.c +++ b/ircd/s_bsd.c @@ -352,7 +352,7 @@ static int completed_connection(struct Client* cptr) * Make us timeout after twice the timeout for DNS look ups */ cli_lasttime(cptr) = CurrentTime; - SetFlag(cptr, FLAG_PINGSENT); + ClearPingSent(cptr); sendrawto_one(cptr, MSG_SERVER " %s 1 %Tu %Tu J%s %s%s +%s6 :%s", cli_name(&me), cli_serv(&me)->timestamp, newts, @@ -581,12 +581,11 @@ static int read_packet(struct Client *cptr, int socket_ready) case IO_SUCCESS: if (length) { - if (!IsServer(cptr)) - cli_lasttime(cptr) = CurrentTime; + cli_lasttime(cptr) = CurrentTime; + ClearPingSent(cptr); + ClrFlag(cptr, FLAG_NONL); if (cli_lasttime(cptr) > cli_since(cptr)) cli_since(cptr) = cli_lasttime(cptr); - ClrFlag(cptr, FLAG_PINGSENT); - ClrFlag(cptr, FLAG_NONL); } break; case IO_BLOCKED: