1
0
mirror of https://github.com/astaxie/beego.git synced 2024-12-23 17:20:50 +00:00
Beego/grace/conn.go

29 lines
388 B
Go
Raw Normal View History

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