Changeset 39 in code for trunk/downstream.go


Ignore:
Timestamp:
Feb 7, 2020, 10:46:44 AM (5 years ago)
Author:
contact
Message:

Add user.forEachUpstream

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/downstream.go

    r38 r39  
    55        "io"
    66        "net"
     7        "strings"
    78
    89        "gopkg.in/irc.v3"
     
    168169
    169170func (c *downstreamConn) register() error {
    170         u := c.srv.getUser(c.username)
     171        u := c.srv.getUser(strings.TrimPrefix(c.username, "~"))
    171172        if u == nil {
     173                c.logger.Printf("failed authentication: unknown username %q", c.username)
    172174                c.messages <- &irc.Message{
    173175                        Prefix:  c.srv.prefix(),
     
    207209        }
    208210
    209         u.lock.Lock()
    210         for _, uc := range u.upstreamConns {
     211        u.forEachUpstream(func(uc *upstreamConn) {
    211212                // TODO: fix races accessing upstream connection data
    212                 if !uc.registered {
    213                         continue
    214                 }
    215213                for _, ch := range uc.channels {
    216214                        if ch.complete {
     
    218216                        }
    219217                }
    220         }
    221         u.lock.Unlock()
    222 
     218        })
    223219        return nil
    224220}
Note: See TracChangeset for help on using the changeset viewer.