Skip to content

Commit

Permalink
frps: fix sometimes no response when frpc login to frps, see fatedier…
Browse files Browse the repository at this point in the history
  • Loading branch information
fatedier committed Dec 26, 2016
1 parent 04a4591 commit 37470c2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/assets/statik/statik.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/cmd/frps/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ func doLogin(req *msg.ControlReq, c *conn.Conn) (ret int64, info string) {
if err != nil {
info = fmt.Sprintf("ProxyName [%s], start proxy error: %v", req.ProxyName, err)
log.Warn(info)
s.Close()
return
}
log.Info("ProxyName [%s], start proxy success", req.ProxyName)
Expand Down
2 changes: 1 addition & 1 deletion src/models/server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ func CreateProxy(s *ProxyServer) error {
if oldServer.Status == consts.Working {
return fmt.Errorf("this proxy is already working now")
}
oldServer.Close()
oldServer.Release()
if oldServer.PrivilegeMode {
delete(ProxyServers, s.Name)
}
Expand Down
15 changes: 11 additions & 4 deletions src/models/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,17 @@ func (p *ProxyServer) Start(c *conn.Conn) (err error) {
}

func (p *ProxyServer) Close() {
p.Release()

// if the proxy created by PrivilegeMode, delete it when closed
if p.PrivilegeMode {
// 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()

Expand All @@ -296,10 +307,6 @@ func (p *ProxyServer) Close() {
}
}
metric.SetStatus(p.Name, p.Status)
// if the proxy created by PrivilegeMode, delete it when closed
if p.PrivilegeMode {
DeleteProxy(p.Name)
}
}

func (p *ProxyServer) WaitUserConn() (closeFlag bool) {
Expand Down

0 comments on commit 37470c2

Please sign in to comment.