Remove network.lock
network.conn is now only accessed from the user goroutine.
This commit is contained in:
parent
1c17d25731
commit
b1494e1065
11
user.go
11
user.go
@ -2,7 +2,6 @@ package soju
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gopkg.in/irc.v3"
|
"gopkg.in/irc.v3"
|
||||||
@ -52,11 +51,9 @@ type network struct {
|
|||||||
ring *Ring
|
ring *Ring
|
||||||
stopped chan struct{}
|
stopped chan struct{}
|
||||||
|
|
||||||
|
conn *upstreamConn
|
||||||
history map[string]uint64
|
history map[string]uint64
|
||||||
lastError error
|
lastError error
|
||||||
|
|
||||||
lock sync.Mutex
|
|
||||||
conn *upstreamConn
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func newNetwork(user *user, record *Network) *network {
|
func newNetwork(user *user, record *Network) *network {
|
||||||
@ -121,8 +118,6 @@ func (net *network) run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (net *network) upstream() *upstreamConn {
|
func (net *network) upstream() *upstreamConn {
|
||||||
net.lock.Lock()
|
|
||||||
defer net.lock.Unlock()
|
|
||||||
return net.conn
|
return net.conn
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,9 +227,7 @@ func (u *user) run() {
|
|||||||
case eventUpstreamConnected:
|
case eventUpstreamConnected:
|
||||||
uc := e.uc
|
uc := e.uc
|
||||||
|
|
||||||
uc.network.lock.Lock()
|
|
||||||
uc.network.conn = uc
|
uc.network.conn = uc
|
||||||
uc.network.lock.Unlock()
|
|
||||||
|
|
||||||
uc.updateAway()
|
uc.updateAway()
|
||||||
|
|
||||||
@ -245,9 +238,7 @@ func (u *user) run() {
|
|||||||
case eventUpstreamDisconnected:
|
case eventUpstreamDisconnected:
|
||||||
uc := e.uc
|
uc := e.uc
|
||||||
|
|
||||||
uc.network.lock.Lock()
|
|
||||||
uc.network.conn = nil
|
uc.network.conn = nil
|
||||||
uc.network.lock.Unlock()
|
|
||||||
|
|
||||||
for _, ml := range uc.messageLoggers {
|
for _, ml := range uc.messageLoggers {
|
||||||
if err := ml.Close(); err != nil {
|
if err := ml.Close(); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user