1
0
mirror of https://github.com/astaxie/beego.git synced 2025-01-10 14:07:12 +00:00
Beego/grace/conn.go

29 lines
388 B
Go
Raw Permalink Normal View History

2015-05-27 23:46:45 +08:00
package grace
2016-01-04 23:34:35 +08:00
import (
"errors"
"net"
)
2015-05-27 23:46:45 +08:00
type graceConn struct {
net.Conn
2015-09-10 16:35:40 +08:00
server *Server
2015-05-27 23:46:45 +08:00
}
2016-01-04 23:34:35 +08:00
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")
}
}
}()
2015-05-27 23:46:45 +08:00
c.server.wg.Done()
return c.Conn.Close()
}