mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 12:30:54 +00:00
recover for conn.Close fix #1333
This commit is contained in:
parent
5c18d02b17
commit
f7ef4aa7e5
@ -1,13 +1,28 @@
|
|||||||
package grace
|
package grace
|
||||||
|
|
||||||
import "net"
|
import (
|
||||||
|
"errors"
|
||||||
|
"net"
|
||||||
|
)
|
||||||
|
|
||||||
type graceConn struct {
|
type graceConn struct {
|
||||||
net.Conn
|
net.Conn
|
||||||
server *Server
|
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()
|
c.server.wg.Done()
|
||||||
return c.Conn.Close()
|
return c.Conn.Close()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user