mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 12:20:54 +00:00
remove contextBuffer fix #396
This commit is contained in:
parent
2ad399db05
commit
419c3fc772
21
router.go
21
router.go
@ -46,7 +46,6 @@ type ControllerRegistor struct {
|
||||
filters map[int][]*FilterRouter
|
||||
enableAuto bool
|
||||
autoRouter map[string]map[string]reflect.Type //key:controller key:method value:reflect.type
|
||||
contextBuffer chan *beecontext.Context //context buffer pool
|
||||
}
|
||||
|
||||
func NewControllerRegistor() *ControllerRegistor {
|
||||
@ -54,7 +53,6 @@ func NewControllerRegistor() *ControllerRegistor {
|
||||
routers: make([]*controllerInfo, 0),
|
||||
autoRouter: make(map[string]map[string]reflect.Type),
|
||||
filters: make(map[int][]*FilterRouter),
|
||||
contextBuffer: make(chan *beecontext.Context, 1000),
|
||||
}
|
||||
}
|
||||
|
||||
@ -440,14 +438,7 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
|
||||
w.Header().Set("Server", BeegoServerName)
|
||||
|
||||
// init context
|
||||
var context *beecontext.Context
|
||||
select {
|
||||
case context = <-p.contextBuffer:
|
||||
context.ResponseWriter = w
|
||||
context.Request = r
|
||||
context.Input.Request = r
|
||||
default:
|
||||
context = &beecontext.Context{
|
||||
context := &beecontext.Context{
|
||||
ResponseWriter: w,
|
||||
Request: r,
|
||||
Input: beecontext.NewInput(r),
|
||||
@ -455,16 +446,6 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
|
||||
}
|
||||
context.Output.Context = context
|
||||
context.Output.EnableGzip = EnableGzip
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if context != nil {
|
||||
select {
|
||||
case p.contextBuffer <- context:
|
||||
default:
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
if context.Input.IsWebsocket() {
|
||||
context.ResponseWriter = rw
|
||||
|
Loading…
Reference in New Issue
Block a user