Skip to content

Commit

Permalink
frps: fix panic caused by frps closing the nil channel, fix fatedier#205
Browse files Browse the repository at this point in the history
  • Loading branch information
fatedier committed Dec 29, 2016
1 parent 90d1384 commit 299bd7b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/models/server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,6 @@ func CreateProxy(s *ProxyServer) error {
ProxyServers[s.Name] = s
metric.SetProxyInfo(s.Name, s.Type, s.BindAddr, s.UseEncryption, s.UseGzip,
s.PrivilegeMode, s.CustomDomains, s.Locations, s.ListenPort)
s.Init()
return nil
}

Expand Down
22 changes: 18 additions & 4 deletions src/models/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ func NewProxyServerFromCtlMsg(req *msg.ControlReq) (p *ProxyServer) {
p.HostHeaderRewrite = req.HostHeaderRewrite
p.HttpUserName = req.HttpUserName
p.HttpPassWord = req.HttpPassWord

p.Init()
return
}

Expand Down Expand Up @@ -298,10 +300,22 @@ func (p *ProxyServer) Release() {
l.Close()
}
}
close(p.ctlMsgChan)
close(p.workConnChan)
close(p.udpSenderChan)
close(p.closeChan)
if p.ctlMsgChan != nil {
close(p.ctlMsgChan)
p.ctlMsgChan = nil
}
if p.workConnChan != nil {
close(p.workConnChan)
p.workConnChan = nil
}
if p.udpSenderChan != nil {
close(p.udpSenderChan)
p.udpSenderChan = nil
}
if p.closeChan != nil {
close(p.closeChan)
p.closeChan = nil
}
if p.CtlConn != nil {
p.CtlConn.Close()
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"strings"
)

var version string = "0.9.1"
var version string = "0.9.2"

func Full() string {
return version
Expand Down

0 comments on commit 299bd7b

Please sign in to comment.