Commit 419c3fc7 authored by astaxie's avatar astaxie

remove contextBuffer fix #396

parent 2ad399db
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment