1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-30 05:56:54 -05:00

fixes for mutex usage

This commit is contained in:
v2ray 2016-01-04 08:40:24 +01:00
parent 59a5f832f6
commit 4271e619fe
4 changed files with 10 additions and 0 deletions

View File

@ -77,7 +77,9 @@ func (this *DokodemoDoor) ListenUDP(port v2net.Port) error {
log.Error("Dokodemo failed to listen on port %d: %v", port, err)
return err
}
this.udpMutex.Lock()
this.udpConn = udpConn
this.udpMutex.Unlock()
go this.handleUDPPackets()
return nil
}
@ -125,7 +127,9 @@ func (this *DokodemoDoor) ListenTCP(port v2net.Port) error {
log.Error("Dokodemo failed to listen on port %d: %v", port, err)
return err
}
this.tcpMutex.Lock()
this.tcpListener = tcpListener
this.tcpMutex.Unlock()
go this.AcceptTCPConnections()
return nil
}

View File

@ -67,7 +67,9 @@ func (this *SocksServer) Listen(port v2net.Port) error {
return err
}
this.accepting = true
this.tcpMutex.Lock()
this.tcpListener = listener
this.tcpMutex.Unlock()
go this.AcceptConnections()
if this.config.UDPEnabled() {
this.ListenUDP(port)

View File

@ -20,8 +20,10 @@ func (this *SocksServer) ListenUDP(port v2net.Port) error {
log.Error("Socks failed to listen UDP on port %d: %v", port, err)
return err
}
this.udpMutex.Lock()
this.udpAddress = v2net.UDPDestination(v2net.IPAddress(this.config.IP()), port)
this.udpConn = conn
this.udpMutex.Unlock()
go this.AcceptPackets()
return nil

View File

@ -56,7 +56,9 @@ func (this *VMessInboundHandler) Listen(port v2net.Port) error {
return err
}
this.accepting = true
this.Lock()
this.listener = listener
this.Unlock()
go this.AcceptConnections()
return nil
}