419c3fc7 by astaxie

remove contextBuffer fix #396

1 parent 2ad399db
Showing 1 changed file with 1 additions and 20 deletions
...@@ -46,7 +46,6 @@ type ControllerRegistor struct { ...@@ -46,7 +46,6 @@ type ControllerRegistor struct {
46 filters map[int][]*FilterRouter 46 filters map[int][]*FilterRouter
47 enableAuto bool 47 enableAuto bool
48 autoRouter map[string]map[string]reflect.Type //key:controller key:method value:reflect.type 48 autoRouter map[string]map[string]reflect.Type //key:controller key:method value:reflect.type
49 contextBuffer chan *beecontext.Context //context buffer pool
50 } 49 }
51 50
52 func NewControllerRegistor() *ControllerRegistor { 51 func NewControllerRegistor() *ControllerRegistor {
...@@ -54,7 +53,6 @@ func NewControllerRegistor() *ControllerRegistor { ...@@ -54,7 +53,6 @@ func NewControllerRegistor() *ControllerRegistor {
54 routers: make([]*controllerInfo, 0), 53 routers: make([]*controllerInfo, 0),
55 autoRouter: make(map[string]map[string]reflect.Type), 54 autoRouter: make(map[string]map[string]reflect.Type),
56 filters: make(map[int][]*FilterRouter), 55 filters: make(map[int][]*FilterRouter),
57 contextBuffer: make(chan *beecontext.Context, 1000),
58 } 56 }
59 } 57 }
60 58
...@@ -440,14 +438,7 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) ...@@ -440,14 +438,7 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
440 w.Header().Set("Server", BeegoServerName) 438 w.Header().Set("Server", BeegoServerName)
441 439
442 // init context 440 // init context
443 var context *beecontext.Context 441 context := &beecontext.Context{
444 select {
445 case context = <-p.contextBuffer:
446 context.ResponseWriter = w
447 context.Request = r
448 context.Input.Request = r
449 default:
450 context = &beecontext.Context{
451 ResponseWriter: w, 442 ResponseWriter: w,
452 Request: r, 443 Request: r,
453 Input: beecontext.NewInput(r), 444 Input: beecontext.NewInput(r),
...@@ -455,16 +446,6 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request) ...@@ -455,16 +446,6 @@ func (p *ControllerRegistor) ServeHTTP(rw http.ResponseWriter, r *http.Request)
455 } 446 }
456 context.Output.Context = context 447 context.Output.Context = context
457 context.Output.EnableGzip = EnableGzip 448 context.Output.EnableGzip = EnableGzip
458 }
459
460 defer func() {
461 if context != nil {
462 select {
463 case p.contextBuffer <- context:
464 default:
465 }
466 }
467 }()
468 449
469 if context.Input.IsWebsocket() { 450 if context.Input.IsWebsocket() {
470 context.ResponseWriter = rw 451 context.ResponseWriter = rw
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!