Skip to content

Commit

Permalink
frps: update
Browse files Browse the repository at this point in the history
  • Loading branch information
fatedier committed Dec 27, 2016
1 parent a5434e3 commit 90d1384
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/models/server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
9 changes: 5 additions & 4 deletions src/models/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,20 +276,21 @@ 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)
}
}

func (p *ProxyServer) Release() {
p.Lock()
defer p.Unlock()

if p.Status != consts.Closed {
p.Status = consts.Closed
for _, l := range p.listeners {
Expand Down

0 comments on commit 90d1384

Please sign in to comment.