Merge pull request #2409 from slingamn/deferred.1

fixes for deferred fakelag handling
This commit is contained in:
Shivaram Lingamneni
2026-06-30 22:28:06 -07:00
committed by GitHub
2 changed files with 11 additions and 11 deletions
+8 -10
View File
@@ -263,10 +263,7 @@ func (s *Session) EndMultilineBatch(label string) (batch MultilineBatch, err err
// heuristics to estimate how much data they used while fakelag was suspended
fakelagBill := (batch.lenBytes / MaxLineLen) + 1
fakelagBillLines := (batch.message.LenLines() * 60) / MaxLineLen
if fakelagBill < fakelagBillLines {
fakelagBill = fakelagBillLines
}
s.deferredFakelagCount = fakelagBill
s.deferredFakelagCount = max(fakelagBill, fakelagBillLines)
if batch.label == "" || batch.label != label || !batch.message.ValidMultiline() {
err = errInvalidMultilineBatch
@@ -744,12 +741,7 @@ func (client *Client) run(session *Session) {
// XXX defer processing of command error parsing until after fakelag
if client.registered {
// apply deferred fakelag
for i := 0; i < session.deferredFakelagCount; i++ {
session.fakelag.Touch("")
}
session.deferredFakelagCount = 0
// touch for the current command
// apply fakelag
var command string
if err == nil {
command = msg.Command
@@ -797,6 +789,12 @@ func (client *Client) run(session *Session) {
go session.client.run(session)
break
}
// apply deferred fakelag immediately, so as to coincide with any delay imposed
// on the client side (avoiding double penalization)
for range session.deferredFakelagCount {
session.fakelag.Touch("")
}
session.deferredFakelagCount = 0
}
}
+3 -1
View File
@@ -592,6 +592,9 @@ func batchHandlerMultiline(server *Server, client *Client, msg ircmsg.Message, r
rb.Label = ""
}
}
if fail {
rb.session.EndMultilineBatch("")
}
} else if tag[0] == '-' {
batch, err := rb.session.EndMultilineBatch(tag[1:])
fail = (err != nil)
@@ -609,7 +612,6 @@ func batchHandlerMultiline(server *Server, client *Client, msg ircmsg.Message, r
}
if fail {
rb.session.EndMultilineBatch("")
if sendErrors {
rb.Add(nil, server.name, "FAIL", "BATCH", "MULTILINE_INVALID", client.t("Invalid multiline batch"))
}