Changeset 179 in code for trunk


Ignore:
Timestamp:
Mar 27, 2020, 11:51:58 PM (5 years ago)
Author:
contact
Message:

Introduce eventUpstreamDisconnected

This allows us to perform cleanup actions in the user goroutine. This
removes the need for pendingLISTsLock.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/downstream.go

    r177 r179  
    10811081                // TODO: support ELIST when supported by all upstreams
    10821082
    1083                 dc.user.pendingLISTsLock.Lock()
    1084                 defer dc.user.pendingLISTsLock.Unlock()
    1085 
    10861083                pl := pendingLIST{
    10871084                        downstreamID:    dc.id,
  • trunk/upstream.go

    r178 r179  
    6464
    6565        // set of LIST commands in progress, per downstream
    66         // access is synchronized with user.pendingLISTsLock
    6766        pendingLISTDownstreamSet map[uint64]struct{}
    6867
     
    152151        }
    153152        close(uc.closed)
    154         for _, log := range uc.logs {
    155                 log.file.Close()
    156         }
    157         uc.endPendingLists(true)
    158153        return nil
    159154}
     
    193188
    194189func (uc *upstreamConn) getPendingList() *pendingLIST {
    195         uc.user.pendingLISTsLock.Lock()
    196         defer uc.user.pendingLISTsLock.Unlock()
    197190        for _, pl := range uc.user.pendingLISTs {
    198191                if _, ok := pl.pendingCommands[uc.network.ID]; !ok {
     
    206199func (uc *upstreamConn) endPendingLists(all bool) (found bool) {
    207200        found = false
    208         uc.user.pendingLISTsLock.Lock()
    209         defer uc.user.pendingLISTsLock.Unlock()
    210201        for i := 0; i < len(uc.user.pendingLISTs); i++ {
    211202                pl := uc.user.pendingLISTs[i]
  • trunk/user.go

    r177 r179  
    1313        msg *irc.Message
    1414        uc  *upstreamConn
     15}
     16
     17type eventUpstreamDisconnected struct {
     18        uc *upstreamConn
    1519}
    1620
     
    7680                }
    7781                uc.Close()
     82                net.user.events <- eventUpstreamDisconnected{uc}
    7883
    7984                net.lock.Lock()
     
    99104
    100105        // LIST commands in progress
    101         pendingLISTsLock sync.Mutex
    102         pendingLISTs     []pendingLIST
     106        pendingLISTs []pendingLIST
    103107}
    104108
     
    164168        for e := range u.events {
    165169                switch e := e.(type) {
     170                case eventUpstreamDisconnected:
     171                        uc := e.uc
     172                        for _, log := range uc.logs {
     173                                log.file.Close()
     174                        }
     175                        uc.endPendingLists(true)
    166176                case eventUpstreamMessage:
    167177                        msg, uc := e.msg, e.uc
Note: See TracChangeset for help on using the changeset viewer.