mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-21 09:36:34 -05:00
fixes for sync logic
This commit is contained in:
parent
4a7f45113a
commit
59a5f832f6
@ -87,6 +87,7 @@ func (this *DokodemoDoor) handleUDPPackets() {
|
||||
buffer := alloc.NewBuffer()
|
||||
this.udpMutex.RLock()
|
||||
if !this.accepting {
|
||||
this.udpMutex.RUnlock()
|
||||
return
|
||||
}
|
||||
nBytes, addr, err := this.udpConn.ReadFromUDP(buffer.Value)
|
||||
@ -132,19 +133,17 @@ func (this *DokodemoDoor) ListenTCP(port v2net.Port) error {
|
||||
func (this *DokodemoDoor) AcceptTCPConnections() {
|
||||
for this.accepting {
|
||||
retry.Timed(100, 100).On(func() error {
|
||||
this.tcpMutex.RLock()
|
||||
defer this.tcpMutex.RUnlock()
|
||||
if !this.accepting {
|
||||
return nil
|
||||
}
|
||||
this.tcpMutex.RLock()
|
||||
defer this.tcpMutex.RUnlock()
|
||||
if this.tcpListener != nil {
|
||||
connection, err := this.tcpListener.AcceptTCP()
|
||||
if err != nil {
|
||||
log.Error("Dokodemo failed to accept new connections: %v", err)
|
||||
return err
|
||||
}
|
||||
go this.HandleTCPConnection(connection)
|
||||
connection, err := this.tcpListener.AcceptTCP()
|
||||
if err != nil {
|
||||
log.Error("Dokodemo failed to accept new connections: %v", err)
|
||||
return err
|
||||
}
|
||||
go this.HandleTCPConnection(connection)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
@ -59,19 +59,17 @@ func (this *HttpProxyServer) Listen(port v2net.Port) error {
|
||||
func (this *HttpProxyServer) accept() {
|
||||
for this.accepting {
|
||||
retry.Timed(100 /* times */, 100 /* ms */).On(func() error {
|
||||
this.Lock()
|
||||
defer this.Unlock()
|
||||
if !this.accepting {
|
||||
return nil
|
||||
}
|
||||
this.Lock()
|
||||
defer this.Unlock()
|
||||
if this.tcpListener != nil {
|
||||
tcpConn, err := this.tcpListener.AcceptTCP()
|
||||
if err != nil {
|
||||
log.Error("Failed to accept HTTP connection: %v", err)
|
||||
return err
|
||||
}
|
||||
go this.handleConnection(tcpConn)
|
||||
tcpConn, err := this.tcpListener.AcceptTCP()
|
||||
if err != nil {
|
||||
log.Error("Failed to accept HTTP connection: %v", err)
|
||||
return err
|
||||
}
|
||||
go this.handleConnection(tcpConn)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
@ -78,16 +78,12 @@ func (this *SocksServer) Listen(port v2net.Port) error {
|
||||
func (this *SocksServer) AcceptConnections() {
|
||||
for this.accepting {
|
||||
retry.Timed(100 /* times */, 100 /* ms */).On(func() error {
|
||||
this.tcpMutex.RLock()
|
||||
defer this.tcpMutex.RUnlock()
|
||||
if !this.accepting {
|
||||
return nil
|
||||
}
|
||||
this.tcpMutex.RLock()
|
||||
if this.tcpListener == nil {
|
||||
this.tcpMutex.RUnlock()
|
||||
return nil
|
||||
}
|
||||
connection, err := this.tcpListener.AcceptTCP()
|
||||
this.tcpMutex.RUnlock()
|
||||
if err != nil {
|
||||
log.Error("Socks failed to accept new connection %v", err)
|
||||
return err
|
||||
|
@ -64,19 +64,17 @@ func (this *VMessInboundHandler) Listen(port v2net.Port) error {
|
||||
func (this *VMessInboundHandler) AcceptConnections() error {
|
||||
for this.accepting {
|
||||
retry.Timed(100 /* times */, 100 /* ms */).On(func() error {
|
||||
this.Lock()
|
||||
defer this.Unlock()
|
||||
if !this.accepting {
|
||||
return nil
|
||||
}
|
||||
this.Lock()
|
||||
defer this.Unlock()
|
||||
if this.listener != nil {
|
||||
connection, err := this.listener.AcceptTCP()
|
||||
if err != nil {
|
||||
log.Error("Failed to accpet connection: %s", err.Error())
|
||||
return err
|
||||
}
|
||||
go this.HandleConnection(connection)
|
||||
connection, err := this.listener.AcceptTCP()
|
||||
if err != nil {
|
||||
log.Error("Failed to accpet connection: %s", err.Error())
|
||||
return err
|
||||
}
|
||||
go this.HandleConnection(connection)
|
||||
return nil
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user