Changeset 175 in code for trunk/user.go


Ignore:
Timestamp:
Mar 27, 2020, 10:08:35 PM (5 years ago)
Author:
contact
Message:

Fix race condition in upstreamConn.Close

upstreamConn.closed was a bool accessed from different goroutines. Use
the same pattern as downstreamConn instead.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/user.go

    r168 r175  
    6565                uc.register()
    6666
     67                // TODO: wait for the connection to be registered before adding it to
     68                // net, otherwise messages might be sent to it while still being
     69                // unauthenticated
    6770                net.lock.Lock()
    6871                net.conn = uc
     
    113116        for _, network := range u.networks {
    114117                uc := network.upstream()
    115                 if uc == nil || !uc.registered || uc.closed {
     118                if uc == nil || !uc.registered {
    116119                        continue
    117120                }
     
    153156                case eventUpstreamMessage:
    154157                        msg, uc := e.msg, e.uc
    155                         if uc.closed {
     158                        if uc.isClosed() {
    156159                                uc.logger.Printf("ignoring message on closed connection: %v", msg)
    157160                                break
Note: See TracChangeset for help on using the changeset viewer.