Add network.upstream helper
This commit is contained in:
parent
4b9168196a
commit
c511a3c895
@ -143,12 +143,7 @@ func (dc *downstreamConn) upstream() *upstreamConn {
|
|||||||
if dc.network == nil {
|
if dc.network == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
return dc.network.upstream()
|
||||||
var upstream *upstreamConn
|
|
||||||
dc.forEachUpstream(func(uc *upstreamConn) {
|
|
||||||
upstream = uc
|
|
||||||
})
|
|
||||||
return upstream
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dc *downstreamConn) marshalEntity(uc *upstreamConn, entity string) string {
|
func (dc *downstreamConn) marshalEntity(uc *upstreamConn, entity string) string {
|
||||||
|
11
user.go
11
user.go
@ -67,6 +67,12 @@ func (net *network) run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (net *network) upstream() *upstreamConn {
|
||||||
|
net.lock.Lock()
|
||||||
|
defer net.lock.Unlock()
|
||||||
|
return net.conn
|
||||||
|
}
|
||||||
|
|
||||||
type user struct {
|
type user struct {
|
||||||
User
|
User
|
||||||
srv *Server
|
srv *Server
|
||||||
@ -99,10 +105,7 @@ func (u *user) forEachNetwork(f func(*network)) {
|
|||||||
func (u *user) forEachUpstream(f func(uc *upstreamConn)) {
|
func (u *user) forEachUpstream(f func(uc *upstreamConn)) {
|
||||||
u.lock.Lock()
|
u.lock.Lock()
|
||||||
for _, network := range u.networks {
|
for _, network := range u.networks {
|
||||||
network.lock.Lock()
|
uc := network.upstream()
|
||||||
uc := network.conn
|
|
||||||
network.lock.Unlock()
|
|
||||||
|
|
||||||
if uc == nil || !uc.registered || uc.closed {
|
if uc == nil || !uc.registered || uc.closed {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user