Let an IRC relay finish its queue read when its connection ends (closes #205)
check / check (push) Waiting to run
check / check (push) Waiting to run
When an IRC listener connection ends, serve cancels the context its relay uses. If the cancel came while the relay was reading the queue, the SQLite driver interrupted the query and reported the connection broken, and the pool closed its only connection. In the tests that deletes the in-memory database, so in TestIntegrationKill alice never got bob's QUIT. In production the new connection runs without PRAGMA foreign_keys = ON. The relay now reads the queue without that cancel. It still stops at its next check of the context. Model: opus-5-5
This commit is contained in:
@@ -32,8 +32,12 @@ func (c *Conn) relayMessages(ctx context.Context) {
|
||||
// still signals waitCh.
|
||||
waitCh := c.brk.Wait(c.sessionID)
|
||||
|
||||
// Drain any available messages.
|
||||
delivered := c.drainQueue(ctx)
|
||||
// Drain any available messages. The drain ignores the
|
||||
// cancel that comes when the connection ends, because a
|
||||
// query cancelled while it runs leaves the SQLite
|
||||
// connection marked broken, and the pool closes it. The
|
||||
// loop still stops on ctx.
|
||||
delivered := c.drainQueue(context.WithoutCancel(ctx))
|
||||
|
||||
if delivered {
|
||||
c.brk.Remove(c.sessionID, waitCh)
|
||||
|
||||
Reference in New Issue
Block a user