From 90d1384bf7bcc06385c7ad03c4dcd88fa42ab89c Mon Sep 17 00:00:00 2001 From: fatedier Date: Wed, 28 Dec 2016 00:56:55 +0800 Subject: [PATCH] frps: update --- src/models/server/config.go | 2 ++ src/models/server/server.go | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/models/server/config.go b/src/models/server/config.go index 7c22c5a..9a4a82b 100644 --- a/src/models/server/config.go +++ b/src/models/server/config.go @@ -395,7 +395,9 @@ func CreateProxy(s *ProxyServer) error { if oldServer.Status == consts.Working { return fmt.Errorf("this proxy is already working now") } + oldServer.Lock() oldServer.Release() + oldServer.Unlock() if oldServer.PrivilegeMode { delete(ProxyServers, s.Name) } diff --git a/src/models/server/server.go b/src/models/server/server.go index 419f6b8..a6d7e4f 100644 --- a/src/models/server/server.go +++ b/src/models/server/server.go @@ -276,10 +276,14 @@ func (p *ProxyServer) Start(c *conn.Conn) (err error) { } func (p *ProxyServer) Close() { + p.Lock() + defer p.Unlock() + + oldStatus := p.Status p.Release() // if the proxy created by PrivilegeMode, delete it when closed - if p.PrivilegeMode { + if p.PrivilegeMode && oldStatus != consts.Closed { // NOTE: this will take the global ProxyServerMap's lock // if we only want to release resources, use Release() instead DeleteProxy(p.Name) @@ -287,9 +291,6 @@ func (p *ProxyServer) Close() { } func (p *ProxyServer) Release() { - p.Lock() - defer p.Unlock() - if p.Status != consts.Closed { p.Status = consts.Closed for _, l := range p.listeners {