mirror of
https://github.com/astaxie/beego.git
synced 2024-12-22 18:10:48 +00:00
recover for conn.Close fix #1333
This commit is contained in:
parent
5c18d02b17
commit
f7ef4aa7e5
@ -1,13 +1,28 @@
|
||||
package grace
|
||||
|
||||
import "net"
|
||||
import (
|
||||
"errors"
|
||||
"net"
|
||||
)
|
||||
|
||||
type graceConn struct {
|
||||
net.Conn
|
||||
server *Server
|
||||
}
|
||||
|
||||
func (c graceConn) Close() error {
|
||||
func (c graceConn) Close() (err error) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
switch x := r.(type) {
|
||||
case string:
|
||||
err = errors.New(x)
|
||||
case error:
|
||||
err = x
|
||||
default:
|
||||
err = errors.New("Unknown panic")
|
||||
}
|
||||
}
|
||||
}()
|
||||
c.server.wg.Done()
|
||||
return c.Conn.Close()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user