Let an IRC relay finish its queue read when its connection ends (closes #205) #206
@@ -32,8 +32,12 @@ func (c *Conn) relayMessages(ctx context.Context) {
|
|||||||
// still signals waitCh.
|
// still signals waitCh.
|
||||||
waitCh := c.brk.Wait(c.sessionID)
|
waitCh := c.brk.Wait(c.sessionID)
|
||||||
|
|
||||||
// Drain any available messages.
|
// Drain any available messages. The drain ignores the
|
||||||
delivered := c.drainQueue(ctx)
|
// 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 {
|
if delivered {
|
||||||
c.brk.Remove(c.sessionID, waitCh)
|
c.brk.Remove(c.sessionID, waitCh)
|
||||||
|
|||||||
Reference in New Issue
Block a user