Protect upstreamConn.history with a lock
This commit is contained in:
parent
af76c3868a
commit
1241bf82aa
@ -555,7 +555,9 @@ func (dc *downstreamConn) register() error {
|
|||||||
|
|
||||||
var seqPtr *uint64
|
var seqPtr *uint64
|
||||||
if firstDownstream {
|
if firstDownstream {
|
||||||
|
uc.lock.Lock()
|
||||||
seq, ok := uc.history[historyName]
|
seq, ok := uc.history[historyName]
|
||||||
|
uc.lock.Unlock()
|
||||||
if ok {
|
if ok {
|
||||||
seqPtr = &seq
|
seqPtr = &seq
|
||||||
}
|
}
|
||||||
@ -583,7 +585,9 @@ func (dc *downstreamConn) register() error {
|
|||||||
dc.user.lock.Unlock()
|
dc.user.lock.Unlock()
|
||||||
|
|
||||||
if lastDownstream {
|
if lastDownstream {
|
||||||
|
uc.lock.Lock()
|
||||||
uc.history[historyName] = seq
|
uc.history[historyName] = seq
|
||||||
|
uc.lock.Unlock()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
})
|
})
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/emersion/go-sasl"
|
"github.com/emersion/go-sasl"
|
||||||
@ -48,11 +49,13 @@ type upstreamConn struct {
|
|||||||
closed bool
|
closed bool
|
||||||
modes modeSet
|
modes modeSet
|
||||||
channels map[string]*upstreamChannel
|
channels map[string]*upstreamChannel
|
||||||
history map[string]uint64
|
|
||||||
caps map[string]string
|
caps map[string]string
|
||||||
|
|
||||||
saslClient sasl.Client
|
saslClient sasl.Client
|
||||||
saslStarted bool
|
saslStarted bool
|
||||||
|
|
||||||
|
lock sync.Mutex
|
||||||
|
history map[string]uint64 // TODO: move to network
|
||||||
}
|
}
|
||||||
|
|
||||||
func connectToUpstream(network *network) (*upstreamConn, error) {
|
func connectToUpstream(network *network) (*upstreamConn, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user