From c7f00edd9dfc403b54ddd5f5e653ece14719563d Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Sat, 9 Feb 2019 16:47:24 +0100 Subject: [PATCH] Quicker handshake when using many CAP requests and/or AUTHENTICATE. I was wondering why the handshake took 4 seconds for a client which authenticates using SASL. Turns out that fake lag was kicking in due to the many "CAP req" commands combined with the other handshake stuff. Now the first 15 (or so) "CAP" requests are "free", without fake lag. --- src/modules/m_cap.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/modules/m_cap.c b/src/modules/m_cap.c index 6ad87ea68..c4a2fe260 100644 --- a/src/modules/m_cap.c +++ b/src/modules/m_cap.c @@ -42,7 +42,7 @@ MOD_INIT(m_cap) ClientCapability c; MARK_AS_OFFICIAL_MODULE(modinfo); - CommandAdd(modinfo->handle, MSG_CAP, m_cap, MAXPARA, M_UNREGISTERED|M_USER); + CommandAdd(modinfo->handle, MSG_CAP, m_cap, MAXPARA, M_UNREGISTERED|M_USER|M_NOLAG); memset(&c, 0, sizeof(c)); c.name = "account-notify"; @@ -354,6 +354,13 @@ CMD_FUNC(m_cap) { struct clicap_cmd *cmd; + /* CAP is marked as "no fake lag" because we use custom fake lag rules: + * Only add a 1 second fake lag penalty if this is the XXth command. + * This will speed up connections considerably. + */ + if (MyConnect(sptr) && (sptr->local->receiveM > 15)) + cptr->local->since++; + if (DISABLE_CAP) { /* I know nothing! */