Changeset 703 in code for trunk/downstream.go


Ignore:
Timestamp:
Nov 17, 2021, 12:13:55 PM (4 years ago)
Author:
contact
Message:

Introduce conn.NewContext

This function wraps a parent context, and returns a new context
cancelled when the connection is closed. This will make it so
operations started from downstreamConn.handleMessage will be
cancelled when the connection is closed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/downstream.go

    r702 r703  
    616616
    617617func (dc *downstreamConn) handleMessage(msg *irc.Message) error {
    618         ctx, cancel := context.WithTimeout(context.TODO(), handleDownstreamMessageTimeout)
     618        ctx, cancel := dc.conn.NewContext(context.TODO())
     619        defer cancel()
     620
     621        ctx, cancel = context.WithTimeout(ctx, handleDownstreamMessageTimeout)
    619622        defer cancel()
    620623
Note: See TracChangeset for help on using the changeset viewer.